YouTube API的间歇性错误:未捕获的异常“Google_IO_Exception”,消息“无法解析主机”www.googleapis.com'

时间:2015-04-19 14:11:02

标签: youtube-api

尝试使用YouTube API检索播放列表和视频信息时出现间歇性错误。我正在使用PHP客户端。这是完整的错误:

PHP Fatal error:  Uncaught exception 'Google_IO_Exception' with message 'Couldn't resolve host 'www.googleapis.com'' in /Test/libs/google-api-php-client-master/src/Google/IO/Curl.php:115
Stack trace:
#0 /Test/libs/google-api-php-client-master/src/Google/IO/Abstract.php(136): Google_IO_Curl->executeRequest(Object(Google_Http_Request))
#1 /Test/libs/google-api-php-client-master/src/Google/Http/REST.php(60): Google_IO_Abstract->makeRequest(Object(Google_Http_Request))
#2 [internal function]: Google_Http_REST::doExecute(Object(Google_Client), Object(Google_Http_Request))
#3 /Test/libs/google-api-php-client-master/src/Google/Task/Runner.php(174): call_user_func_array(Array, Array)
#4 /Test/libs/google-api-php-client-master/src/Google/Http/REST.php(46): Google_Task_Runner->run()
#5 /Test/libs/google-api-php-client-master/src/Google/Client.php(590): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#6 /Test/libs/google-api-php-client-master/src/Google/Service/Resource.php(228): Google_Client->execute(Objec in /Test/libs/google-api-php-client-master/src/Google/IO/Curl.php on line 115

此外,这是我的代码:

$client = new Google_Client();
$client->setDeveloperKey("*****************");

$service = new Google_Service_YouTube($client);
$results = $service->playlists->listPlaylists("snippet", array("channelId" => "UCkyQHj9ceKEVZR2qO0LUUdg", "maxResults" => 50));
$results = $service->playlistItems->listPlaylistItems("snippet", array("playlistId" => "PL2Kceei6lZdpFRvkRyQMStS0UknLE3mKV", "maxResults" => 50));

错误不一致。它不会一直发生。如果它经常发生,我必须刷新浏览器几次,然后才能工作。

有没有人遇到过这个?

0 个答案:

没有答案