首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >请求Gracenote超时

请求Gracenote超时
EN

Stack Overflow用户
提问于 2014-08-14 02:58:48
回答 3查看 322关注 0票数 1

我使用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中

下面是我非常简单的代码:

代码语言:javascript
复制
<?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);

做错什么了?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-08-14 03:19:53

您应该使用try/catch来包围gracenote调用,gracenote客户端抛出各种异常

例如https://github.com/richadams/php-gracenote/blob/25e0346443dd5026a4bc9f0d62a589d44bdc133b/php-gracenote/HTTP.class.php#L110

票数 0
EN

Stack Overflow用户

发布于 2014-08-31 12:18:29

我遇到了同样的问题,每10个请求中就有9个请求会因以下错误而超时:

代码语言:javascript
复制
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行,从而能够永久修复这个问题。

代码语言:javascript
复制
    curl_setopt($this->_ch, CURLOPT_SSLVERSION,     3);
票数 1
EN

Stack Overflow用户

发布于 2014-10-17 05:29:38

正如Yavor所建议的,这个问题与服务器上的SSL设置有关。但是我们现在已经增加了对TLSV1.2的完全支持,所以您的原始代码应该可以使用默认的SSL设置。

您不应该使用SSL v3,因为存在贵宾狗漏洞。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25299334

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档