我使用PHP脚本访问gracenote的WEB。虽然它有时工作,但它给我一个超时错误,大多数情况下。下面是我遇到的错误:
异常: code=2001,message=Request到Gracenote WebAPI超时。,ext= PHP致命错误:未命名的异常' Gracenote \ WebAPI \GNException‘带有消息’请求Gracenote WebAPI超时‘。在/home/kubuntu/Downloads/php-gracenote-master/php-gracenote-master/php-gracenote/HTTP.class.php:1中
下面是我非常简单的代码:
<?php
include("./php-gracenote/Gracenote.class.php");
$clientID = "";
$clientTag = "";
$api = new Gracenote\WebAPI\GracenoteWebAPI($clientID, $clientTag);
$userID = "xxxxxxxxxxxxxxxxxx";
echo "UserID = ".$userID."\n";
$results = $api->searchArtist("Bob Dylan");
var_dump($results);做错什么了?
发布于 2014-08-14 03:19:53
您应该使用try/catch来包围gracenote调用,gracenote客户端抛出各种异常
发布于 2014-08-31 12:18:29
我遇到了同样的问题,每10个请求中就有9个请求会因以下错误而超时:
http: external request POST url=https://1234567.web.cddbp.net/webapi/xml/1.0/, timeout=20000 exception: code=2001, message=Request to a Gracenote WebAPI timed out., ext=0
Fatal error: Uncaught exception 'Gracenote\WebAPI\GNException' with message 'Request to a
Gracenote WebAPI timed out.' in /usr/samba/dev/gracenote/php-gracenote/php-
gracenote/HTTP.class.php:110 Stack trace: #0 /usr/samba/dev/gracenote/php-gracenote/php-
gracenote/HTTP.class.php(94): Gracenote\WebAPI\HTTP->validateResponse(false) #1
/usr/samba/dev/gracenote/php-gracenote/php-gracenote/HTTP.class.php(144): Gracenote\WebAPI\HTTP-
>execute() #2 /usr/samba/dev/gracenote/php-gracenote/php-gracenote/Gracenote.class.php(59):
Gracenote\WebAPI\HTTP->post('<QUERIES>? ...') #3 /usr/samba/dev/gracenote/php-
gracenote/example.php(31): Gracenote\WebAPI\GracenoteWebAPI->register() #4 {main} thrown in
/usr/samba/dev/gracenote/php-gracenote/php-gracenote/HTTP.class.php on line 110 原因(我怀疑)是由于curl连接缺少SSL选项参数。
我在HTTP.class.php中将其添加到第38行,从而能够永久修复这个问题。
curl_setopt($this->_ch, CURLOPT_SSLVERSION, 3);发布于 2014-10-17 05:29:38
正如Yavor所建议的,这个问题与服务器上的SSL设置有关。但是我们现在已经增加了对TLSV1.2的完全支持,所以您的原始代码应该可以使用默认的SSL设置。
您不应该使用SSL v3,因为存在贵宾狗漏洞。
https://stackoverflow.com/questions/25299334
复制相似问题