Search code examples
gracenote

Request to Gracenote Web API timed out


I am using a PHP script to access the WEB API of gracenote. Though it works sometimes, it gives me a time out error most of the times. Here is the error I am getting:

exception: code=2001, message=Request to a Gracenote WebAPI timed out., ext= PHP Fatal error: Uncaught exception 'Gracenote\WebAPI\GNException' with message 'Request to a Gracenote WebAPI timed out.' in /home/kubuntu/Downloads/php-gracenote-master/php-gracenote-master/php-gracenote/HTTP.class.php:1

Here is my very simple code:

<?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);

What am doing wrong?


Solution

  • You should use try/catch to surround gracenote api calls, gracenote HTTP client throws various of exceptions

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