twilio
2012-03-20 68 views 3 likes 
3
<?php 
$options = array(
    "StatusCallback" => 'http://173.203.104.63/call/out/log-callback.php? id='.$id 
); 

$client = new Services_Twilio($sid, $token, $version); 
try { 
    // Initiate a new outbound call 
    $call = $client->account->calls->create(
    $phonenumber, // The number of the phone initiating the call 
    $cphonenumber, // The number of the phone receiving call 
    '60', 
    'http://173.203.104.63/call/out/three.php?id='.$id, // The URL Twilio will request when the call is answered 
    $options 
); 
... 

在這裏,我已經建立了網址爲statuscallback但我不知道天氣是重定向或不以及如何獲得該網址如何使用StatusCallback網址在twilio

+0

嗨,'StatusCallback' URL會只有在通話完成時纔會被請求。您應該使用Url在呼叫連接時請求該URL。您應該能夠知道調試器中請求了哪個URL。 – 2012-03-20 18:49:29

回答

1

的第三個參數應該我callstatus值是網址,而不是'60'。通話結束後,所有數據將作爲正常的POSTGET參數(取決於您在帳戶中設置的內容)傳遞到您的回叫網址。

0

你忘了指定statuscallback網址的方法

我已經在這裏的代碼包括它

<?php 
//"StatusCallbackMethod" can be "POST" or "GET", depends on the way you recieve it on your StatusCallback, 
    $options = array(
     "StatusCallbackMethod"=>"GET", 
     "StatusCallback" => 'http://173.203.104.63/call/out/log-callback.php? id='.$id 
    ); 

$client = new Services_Twilio($sid, $token, $version); 
try { 
    // Initiate a new outbound call 
    $call = $client->account->calls->create(
    $phonenumber, // The number of the phone initiating the call 
    $cphonenumber, // The number of the phone receiving call 
    '60', 
    'http://173.203.104.63/call/out/three.php?id='.$id, // The URL Twilio will request when the call is answered 
    $options 
); 
0
<?php 
// Get the PHP helper library from twilio.com/docs/php/install 
require_once('/path/to/twilio-php/Services/Twilio.php'); // 

// Your Account Sid and Auth Token from twilio.com/user/account 
$sid = "AC5ef8732a3c49700934481addd5ce1659"; 
$token = "{{ auth_token }}"; 
$client = new Services_Twilio($sid, $token); 
$call = $client->account->calls->create("+18668675309", "+14155551212",  "http://demo.twilio.com/docs/voice.xml", array(
    "Method" => "GET", 
    "StatusCallback" => "https://www.myapp.com/events", 
    "StatusCallbackMethod" => "POST", 
    "StatusCallbackEvent" => array("initiated", "ringing", "answered", "completed"), 
)); 
echo $call->sid; 

請參閱https://www.twilio.com/docs/api/rest/making-calls

+0

爲什麼要看那裏?由於發佈的代碼是從示例4複製的?它有什麼作用?你認爲它有什麼幫助? OP代碼的關鍵點是什麼? – dakab 2016-02-02 07:16:30

相關問題