这里是 Twilio 开发者宣传员。
要处理此服务器端,您需要从客户端拨入<Conference>,然后拨入generate a call to the number your user was calling using the REST API,将他们也引导到会议中。
因此,您对来自客户端的原始拨号的响应应该如下所示:
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$number = htmlspecialchars($_REQUEST["TO"]);
// Generate a call to the other party
$call = $client->calls->create(
$number,
$from,
array("url" => "http://example.com/conference?conference_name=EXAMPLE")
);
$response = new Twiml;
$limit = getLimit($TWILIO_CALLER_ID, 1);
$dial = $response->dial(array('callerId' => $TWILIO_CALLER_ID, 'timelimit' => $limit));
$dial->conference("EXAMPLE");
header("Content-Type: text/xml");
echo $response;
这将使呼叫者进入会议并拨打接收者。当他们接听电话时,您将获得一个指向 URL 的 webhook(在这种情况下为http://example.com/conference?conference_name=EXAMPLE)。您需要使用同一会议室响应该 URL。
$response = new Twiml;
$dial = $response->dial();
$dial->conference($_REQUEST['conference_name']);
header("Content-Type: text/xml");
echo $response;
然后,当您想提醒剩余时间时,您需要再次拨入会议,这次只需使用 TwiML 的 <Say> 或 <Play> 读出提醒。
您需要设置一个指向此会议的号码以拨入。然后在时间限制临近时拨打该号码并使用显示该消息的 URL。
require_once '/path/to/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$client = new Client($sid, $token);
$number = $YOUR_CONFERENCE_NUMBER;
// Generate a call to the other party
$call = $client->calls->create(
$number,
$TWILIO_CALLER_ID,
array("url" => "http://example.com/time_message")
);
最后,您需要使用 TwiML 响应 /time_message 端点说出消息然后挂断。
$text1 = "Your limit is";
$text2 = "seconds";
$response = new Twiml;
$response->say($text1 . "10 seconds" . $text2)
$response->hangup();
header("Content-Type: text/xml");
echo $response;
让我知道这是否有帮助。