(I am using the latest version of this library: https://github.com/google/google-api-php-client)
In short, my script works perfectly on localhost, but whenever I upload to our production or staging environments it fails.
I am now using a really simple test script from this tutorial: http://blog.salteh.net/2012/10/google-analytics-api-and-service-accounts/
Again, this works perfectly on localhost, but errors on our production and staging servers.
The error is:
HTTP Error: Unable to connect
From our error log, we get:
2014-01-29 10:14:43 /classes/google-api-php-client-read-only/src/Google/IO/Stream.php 115 php_error {"error_message":"file_get_contents(compress.zlib:\/\/https:\/\/accounts.google.com\/o\/oauth2\/token): failed to open stream: operation failed"} php_error
I believe this must be due to either file_get_contents() not working correctly or an error with the zlib compression.
I've therefore created a simple script to test (https://gist.github.com/jonmilsom/7771566cf55e042b4826) but this works fine on both localhost AND the staging & production environments.... how can I debug this further?