簡體   English   中英

如何在twilio中使用StatusCallback url

[英]how to use StatusCallback url in twilio

<?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設置了網址,但我不知道天氣是否重定向,以及如何在該網址中獲取我的callstatus值

第三個參數應該是URL,而不是'60' 通話結束后,所有數據都將作為普通的POSTGET參數傳遞到您的回調網址(具體取決於您在帳戶中設置的內容)。

你忘了為statuscallback url指定方法

我把它包含在代碼中

    <?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
  );
<?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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM