在 iOS 应用程序中使用 twilio 同时向用户拨出电话

Simultaneous outgoing call to user using twilio in iOS Application

我想对用户进行本地调用,直到用户接听电话(递归调用)。如果是语音邮件,也可以这样做。是否可以在我的 iOS 应用程序中使用 Twilio

另外我想知道电话是人工接听还是机器接听

如果是,请给我一些解决方案。

你可以通过利用 StatusCallBack 来做到这一点,像这样:

    $sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
    $token = "your_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",
    "IfMachine"=>"Hangup",
    "StatusCallback" => "https://www.myapp.com/check_call_status.php",
    "StatusCallbackMethod" => "POST"
    ));

StatusCallBack: A URL that Twilio will send asynchronous webhook requests to on every call event specified in the StatusCallbackEvent parameter. If no event is present, Twilio will send completed by default. If an ApplicationSid parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted).

因此,在您的 StatusCallBack URL (https://www.myapp.com/check_call_status.php) 中,您将有一些逻辑来确定呼叫是否已接听,以及是否由人而不是答录机接听。您的 StatusCallBack 端点看起来像这样:

<?php 

if($_REQUEST['CallStatus'] == 'no-asnwer' || $_REQUEST['AnsweredBy'] == 'machine'){
        // call again!
        $sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
        $token = "your_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",
        "IfMachine"=>"Hangup",
        "StatusCallback" => "https://www.myapp.com/check_call_status.php",
        "StatusCallbackMethod" => "POST"
        ));
}