Update twilio.api.php

This commit is contained in:
Namhyeon Go 2019-04-15 15:18:52 +09:00 committed by GitHub
parent 8160577d6e
commit 3a5138a3f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,18 @@
* @documentation https://www.twilio.com/docs/sms/send-messages * @documentation https://www.twilio.com/docs/sms/send-messages
*/ */
if(!check_function_exists("twilio_get_config")) {
function twilio_get_config() {
$config = get_config();
return array(
"sid" => get_value_in_array("twilio_sid", $config, ""),
"token" => get_value_in_array("twilio_token", $config, ""),
);
}
}
if(!check_function_exists("twilio_send_message")) { if(!check_function_exists("twilio_send_message")) {
function twilio_send_message($message, $from, $to, $sid, $token) { function twilio_send_message($message, $from, $to, $sid, $token) {
$response = false; $response = false;
@ -15,8 +27,8 @@ if(!check_function_exists("twilio_send_message")) {
$request_url = sprintf("https://api.twilio.com/2010-04-01/Accounts/%s/Messages.json", $sid); $request_url = sprintf("https://api.twilio.com/2010-04-01/Accounts/%s/Messages.json", $sid);
$response = get_web_json($request_url, "post", array( $response = get_web_json($request_url, "post", array(
"headers" = array( "headers" = array(
"Authentication" => array("Basic", $sid, $token),
"Content-Type" => "application/x-www-form-urlencoded", "Content-Type" => "application/x-www-form-urlencoded",
"Authentication" => array("Basic", $sid, $token),
), ),
"data" => array( "data" => array(
"Body" => $message, "Body" => $message,
@ -42,8 +54,8 @@ if(!check_function_exists("twilio_send_voice")) {
$request_url = sprintf("https://api.twilio.com/2010-04-01/Accounts/%s/Calls.json", $sid); $request_url = sprintf("https://api.twilio.com/2010-04-01/Accounts/%s/Calls.json", $sid);
$response = get_web_json($request_url, "post", array( $response = get_web_json($request_url, "post", array(
"headers" = array( "headers" = array(
"Authentication" => array("Basic", $sid, $token),
"Content-Type" => "application/x-www-form-urlencoded", "Content-Type" => "application/x-www-form-urlencoded",
"Authentication" => array("Basic", $sid, $token),
), ),
"data" => array( "data" => array(
"Url" => $url, "Url" => $url,