<?php
// Include the bundled autoload from the Twilio PHP Helper Library
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = '8XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
// In production, these should be environment variables. E.g.:
// $auth_token = $_ENV["TWILIO_ACCOUNT_SID"]
// A Twilio number you own with Voice capabilities
$twilio_number = "+12244073476";
// Where to make a voice call (your cell phone?)
$to_number = '+22678733599';
$client = new Client($account_sid, $auth_token);
try {
$client->account->calls->create(
$to_number,
$twilio_number,
array(
// two url can't function because the first url will be erase by the value of the second
"url" => "http://demo.twilio.com/docs/voice.xml"
)
);
// echo "Started call : " . $client->sid;
} catch (Exception $e) {
echo "Error : " . $e->getMessage();
}
?>
我从twilio号码开始打电话到那个电话号码,可以,但是无法沟通,接了电话怎么沟通?
1条答案
按热度按时间3bygqnnd1#
Twilio开发人员宣传员。
你的标题说你想把一个浏览器连接到一个电话上。但是,你的代码只显示了REST API的使用。
要创建从浏览器到电话的呼叫,你需要使用Twilio Voice SDK。我建议你阅读运行Voice SDK quick start application的说明。这将解释如何从浏览器到电话进行呼叫,并给予你一个示例应用程序来运行和研究。快速启动应用程序是完整的文档。