Google API php快速入门listFiles()500内部错误

时间:2015-10-09 19:36:12

标签: php google-api-php-client

我尝试了Google的Example CLI PHP codelistFiles()方法会从Google的服务器中引发500内部错误,如堆栈跟踪所示:

  

bash-4.2 $ php test.php       PHP致命错误:在/home/ben/.../vendor/google/apiclient/src/Google/Http/REST中显示错误消息“Google_Service_Exception”,并显示错误“正在调用GET https://www.googleapis.com/drive/v2/files?maxResults=10:(500)内部错误” .PHP:79       堆栈跟踪:       #0 /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php(44):Google_Http_REST :: decodeHttpResponse(Object(Google_Http_Request))       #1 /home/ben/.../vendor/google/apiclient/src/Google/Client.php(556):Google_Http_REST :: execute(Object(Google_Client),Object(Google_Http_Request))       #2 /home/ben/.../vendor/google/apiclient/src/Google/Service/Resource.php(195):Google_Client-> execute(Object(Google_Http_Request))       #3 /home/ben/.../vendor/google/apiclient/src/Google/Service/Drive.php(1783):Google_Service_Resource-> call('list',Array,'Google_Service _...')       #4 /home/ben/.../test.php(78):Google_Service_Drive_Files_Resource-> listFiles(Arra in /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php第79行

我删除了已保存的凭据并再次尝试。这没有帮助:

  

bash-4.2 $ php test.php       在浏览器中打开以下链接:       https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=urn%3A       IETF%3Awg%3Aoauth%3A2.0%3Aoob&安培; CLIENT_ID = ...&安培;范围= HTTPS%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&安培; ACCESS_TYPE =离线&安培; approval_prompt =汽车       输入验证码: ...       凭据保存到/home/ben/.credentials/drive-php-quickstart.json       PHP致命错误:在/home/ben/.../vendor/google/apiclient/src/Google/Http/REST中显示错误消息“Google_Service_Exception”,并显示错误“正在调用GET https://www.googleapis.com/drive/v2/files?maxResults=10:(500)内部错误” .PHP:79       堆栈跟踪:       #0 /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php(44):Google_Http_REST :: decodeHttpResponse(Object(Google_Http_Request))       #1 /home/ben/.../vendor/google/apiclient/src/Google/Client.php(556):Google_Http_REST :: execute(Object(Google_Client),Object(Google_Http_Request))       #2 /home/ben/.../vendor/google/apiclient/src/Google/Service/Resource.php(195):Google_Client-> execute(Object(Google_Http_Request))       #3 /home/ben/.../vendor/google/apiclient/src/Google/Service/Drive.php(1783):Google_Service_Resource-&gt; call('list',Array,'Google_Service _...')<登记/>       #4 /home/ben/.../test.php(78):Google_Service_Drive_Files_Resource-&gt; listFiles(Arra in /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php第79行

我搜索了github问题和标记为google-api-php-client的stackoverflow问题,但没有找到任何线索。我登录开发者控制台并单击了Logs,结果显示了文本

  

无法加载。

如何从Google获取有关500个错误的更详细信息?

1 个答案:

答案 0 :(得分:0)

尝试将此添加到调用Google Drive API的文件中的代码的开头 date_default_timezone_set('America / New_York')//更改你想要的时区

另外请确保设置了Google云端硬盘中的文件夹权限。