我在opentok库中尝试了示例存档,它运行正常。但是,当我在localhost或服务器中的网站上尝试时,我总是会收到此错误:
致命错误:未捕获异常'Guzzle \ Http \ Exception \ ClientErrorResponseException',并显示消息'客户端错误响应 [状态代码] 404 [原因短语]未找到 [url] https://api.opentok.com/v2/partner/44968642/archive'/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(Object(Guzzle \ Http \ Message \ EntityEnclosingRequest),Object(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 \ Event),'request.error',Object(Symfony \ Component \ Eve in / var / www / shabetaro / wp-content / themes / chico-child / library / opentok / opentok / src / OpenTok / Util / Client第200行的.php
代码:
JQUERY
$.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');
OPENTOK
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;
}
}