OpenTok PHP SDK createSession无效

时间:2017-10-03 23:31:11

标签: php tokbox

我刚安装了最新的opentok php sdk。

我无法创建会话,这非常令人沮丧。

我知道SDK已正确导入,因为我的第一次调用有效。这是我的代码。

<?PHP
require("./../classes/opentok.phar");

use OpenTok\OpenTok;
use OpenTok\Session;
use OpenTok\Role; 
use OpenTok\MediaMode;

$API_KEY            = '45972332';
$API_SECRET         = 'HIDDEN_FOR_MY_PROTECTION';

$apiObj             = new OpenTok($API_KEY, $API_SECRET);

var_dump($apiObj); // this returned successful data.

$session            = $apiObj->createSession(array('mediaMode' => 
MediaMode::RELAYED)); // this errors out the script.
?>

这是它返回给我的错误。

  

致命错误:未捕获异常'Guzzle \ Http \ Exception \ ClientErrorResponseException',消息'客户端错误响应[状态代码] 403 [原因短语]禁止[url] https://api.opentok.com/session/create'在phar:/// var / WWW / HTML / API /类/ opentok.phar /供应商/狂饮/狂饮/ SRC /狂饮/ HTTP /异常/ BadResponseException.php:43
  堆栈跟踪:
  #0 phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145):Guzzle \ Http \ Exception \ BadResponseException: :factory(对象(Guzzle \ Http \ Message \ EntityEnclosingRequest),对象(Guzzle \ Http \ Message \ Response))
  #1 [内部函数]:Guzzle \ Http \ Message \ Request :: onRequestError(Object(Guzzle \ Common \ Event),'request.error',Object(Symfony \ Component \ EventDispatcher \ EventDispatcher))
  #2 phar:///var/www/html/API/classes/opentok.phar/vendor/symfony/event-dispatcher/EventDispatcher.php(184):call_user_func(Array,Object(Guzzle \ Common \ Event),' request.error',Object(Symfony \ Component \ EventDispatcher \ EventDispatcher))
  #3 phar:/// var / www / html / API / in phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException第43行的.php

1 个答案:

答案 0 :(得分:2)

当时钟与OpenTok服务器不同步时,我遇到过类似的问题。见OpenTok constructor/create_session fails when not running venv