我在 opentok 库中尝试了示例存档,它工作正常。但是当我在本地主机或服务器的网站上尝试它时,我总是收到此错误:
致命错误:未捕获的异常“Guzzle\Http\Exception\ClientErrorResponseException”与消息“客户端错误响应 [状态代码] 404 [原因短语] 未找到 [url] https://api.opentok.com/v2/partner/44968642/存档'在 /var/www/shabetaro/wp-content/themes/chico-child/library/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43 堆栈跟踪:
#0 /var/www/shabetaro/wp-content/themes/chico-child/library/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145): Guzzle\Http\Exception\BadResponseException::factory (对象(Guzzle\Http\Message\EntityEnclosureRequest),对象(Guzzle\Http\Message\Response))
#1 [内部函数]:Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#2 /var/www/shabetaro/wp-content/themes/chico-child/library/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Guzzle\Common\事件),'request.error',对象(Symfony\Component\Eve in /var/www/shabetaro/wp-content/themes/chico-child/library/opentok/opentok/src/OpenTok/Util/Client.php on第 200 行
代码:
查询
$.ajax({
url: ggeajax.ajaxurl,
data: {
'action': 'gge_start_archive',
'api' : api
}
});
PHP
function gge_start_archive()
{
$api = $_REQUEST['api'];
$opentok = getInstance('Helper_Opentok');
gge_log("Starting archive", array('sessionID' => "Archive"));
$archiveID = $opentok->start_archive($api['sessionID'], "Archive");
die();
}
add_action('wp_ajax_gge_start_archive', 'gge_start_archive');
开放式
use OpenTok\OpenTok;
use OpenTok\Session;
use OpenTok\Role;
use OpenTok\MediaMode;
class Helper_Opentok {
public function initialize()
{
$option = get_option('chico_settings');
return new OpenTok($option['opentok_api'], $option['opentok_token']);
}
public function start_archive($sessionId, $name)
{
$opentok = $this->initialize();
$archiveId = $opentok->startArchive($sessionId, $name);
gge_log("Generate archiveId", array('archiveId' => $archiveId, 'name' => $name, 'user' => get_userdata(get_current_user_id())));
return $archiveId;
}
}