I am trying to use Google Analytics API. After I enabled Analytic API I received my client_secrets.p12 and downloaded the API client library. I then replaced the service_account_email
and changed the key_file_location
. How ever when I run my script 'HelloAnalytics.php'
, I get an error:
PHP Fatal error: Uncaught exception 'Google_IO_Exception' with message 'Failed to connect to accounts.google.com port 443: Operation timed out' in /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Curl.php:115
Stack trace:
0 /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Abstract.php(136): Google_IO_Curl->executeRequest(Object(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} thrown in /Users/weiqi.tan/Downloads/ga_api/google-api-php-client/src/Google/IO/Curl.php on line 115
I don't know if anyone else ever had the same problem. Please tell me why this happened and how to solve it.
I had same problem today so
I just disable the firewall and it worked for me
I am using avg internet security