简体   繁体   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
  );
...

here i have set up url for statuscallback but i dont know weather it is redirecting or not and also how to get my callstatus values in that url 在这里我已经为statuscallback设置了网址,但我不知道天气是否重定向,以及如何在该网址中获取我的callstatus值

The 3rd argument should be the URL, not '60' . 第三个参数应该是URL,而不是'60' Once the call ends, all the data will be passed to your callback URL as normal POST or GET parameters (depending on what you've setup in your account). 通话结束后,所有数据都将作为普通的POSTGET参数传递到您的回调网址(具体取决于您在帐户中设置的内容)。

you have forgotten to specify the method for statuscallback url 你忘了为statuscallback url指定方法

i have included it here in the code 我把它包含在代码中

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

Please see https://www.twilio.com/docs/api/rest/making-calls 请参阅https://www.twilio.com/docs/api/rest/making-calls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM