【发布时间】:2024-04-12 21:20:02
【问题描述】:
我正在尝试使用 Google Analytics API。启用分析 API 后,我收到了 client_secrets.p12 并下载了 API 客户端库。然后我替换了service_account_email 并更改了key_file_location。当我运行我的脚本'HelloAnalytics.php' 时,我得到了一个错误:
PHP 致命错误:未捕获的异常“Google_IO_Exception”与 消息“连接到accounts.google.com端口443失败:操作 超时'在 /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Curl.php:115
堆栈跟踪:
0 /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Abstract.php(136): Google_IO_Curl->executeRequest(对象(Google_Http_Request)) 1 /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/Auth/OAuth2.php(342): Google_IO_Abstract->makeRequest(Object(Google_Http_Request)) 2 /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/Auth/OAuth2.php(314): Google_Auth_OAuth2->refreshTokenRequest(Array) 3 /Users/weiqi.tan/Downloads/ga_api/HelloAnalytics.php(30): Google_Auth_OAuth2->refreshTokenWithAssertion(Object(Google_Auth_AssertionCredentials)) 4 /Users/weiqi.tan/Downloads/ga_api/HelloAnalytics.php(105): getService() 5 {main} 抛出 /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Curl.php 在第 115 行
我不知道其他人是否也遇到过同样的问题。请告诉我为什么会发生这种情况以及如何解决。
【问题讨论】:
-
1.你能
ping accounts.google.com吗? 2.可以telnet accounts.google.com 443吗?
标签: php google-api google-analytics-api google-api-php-client service-accounts