OpenTok PHP SDK createSession not working

别来无恙 提交于 2019-12-23 05:08:06

问题


I've just installed the latest php sdk of opentok.

I cannot get a session to be created and it's extremely frustrating.

I know the SDK is correctly imported because my first call works. Here is my code.

<?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.
?>

This is the error it returns to me.

Fatal error: Uncaught exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response [status code] 403 [reason phrase] Forbidden [url] https://api.opentok.com/session/create' in phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43
Stack trace:
#0 phar:///var/www/html/API/classes/opentok.phar/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145): Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response))
#1 [internal function]: 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.php on line 43


回答1:


I've seen similar issues to this when the clock is out of sync with the OpenTok server. See OpenTok constructor/create_session fails when not running venv



来源:https://stackoverflow.com/questions/46554925/opentok-php-sdk-createsession-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!