Php 连接到Twilio视频API

Php 连接到Twilio视频API,php,twilio,twilio-php,twilio-api,Php,Twilio,Twilio Php,Twilio Api,我正试图从指南中测试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_S

我正试图从指南中测试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:undefined。。。一直如此


希望能找到解决办法。

这里是Twilio福音传道者。我建议在浏览器中打开Javascript控制台,确保正确地从网页返回令牌,并且没有发生其他客户端错误。如果有,请随意将这些错误放入您的问题中,我们可以帮助您解决这些问题。@devinReader:没有错误,令牌和标识已成功从服务器返回。@qwery_coder:您能将令牌放入测试仪吗。在有效负载部分,您应该看到您的帐户SID、API密钥SID和配置文件SID。@devinReader:我试过了,返回了所有有效值。@qwery_coder:您能在index.js(console.log行)的第22行设置一个断点,看看
error
对象在这里是否为NullTwio evangelist吗。我建议在浏览器中打开Javascript控制台,确保正确地从网页返回令牌,并且没有发生其他客户端错误。如果有,请随意将这些错误放入您的问题中,我们可以帮助您解决这些问题。@devinReader:没有错误,令牌和标识已成功从服务器返回。@qwery_coder:您能将令牌放入测试仪吗。在有效负载部分,您应该看到您的帐户SID、API密钥SID和配置文件SID。@devinReader:我试过了,返回了所有有效值。@qwery_coder:您能在index.js(console.log行)的第22行设置一个断点,看看
error
对象是否为空吗