我正在尝试从指南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(),
));
令牌已正确生成并正确传递到本地主机,但日志始终显示无法连接到 Twilio:未定义...。
希望能得到解决这个问题。