连接到Twilio Video API

时间:2016-07-12 10:10:22

标签: php twilio twilio-php twilio-api

我正试图从指南 QuickStart guide测试chrome中的twilio-php视频sdk。从twilio api控制台(api密钥和配置文件sid)获得所需的凭据,并将其粘贴到给定的代码中以生成访问令牌:

require_once('./twilio-php/Services/Twilio.php');
require_once('./randos.php');

$TWILIO_ACCOUNT_SID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$TWILIO_CONFIGURATION_SID = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
$TWILIO_API_KEY = 'zzzzzzzzzzzzzzzzzzzzzzzzzz';
$TWILIO_API_SECRET = 'kkkkkkkkkkkkkkkkkkkkkkkkk';

// An identifier for your app - can be anything you'd like
$appName = 'TwilioVideoDemo';

// choose a random username for the connecting user
$identity = randomUsername();

// Create access token, which we will serialize and send to the client
$token = new Services_Twilio_AccessToken(
    $TWILIO_ACCOUNT_SID, 
    $TWILIO_API_KEY, 
    $TWILIO_API_SECRET, 
    3600, 
    $identity
);

// Grant access to Conversations
$grant = new Services_Twilio_Auth_ConversationsGrant();
$grant->setConfigurationProfileSid($TWILIO_CONFIGURATION_SID);
$token->addGrant($grant);

// return serialized token and the user's randomly generated ID
echo json_encode(array(
    'identity' => $identity,
    'token' => $token->toJWT(),
));

令牌生成正确并正确传递给localhost,但日志显示无法连接到Twilio:undefined ......

Screenshot of log

希望得到解决方案。

0 个答案:

没有答案