Google-api-php-client: Problème de proxy
Bonjour à tous,
J'ai un soucis avec la librairie PHP "google-api-php-client" qui me permet d'interroger l'API de Google Analytics.
https://github.com/google/google-api-php-client
Mon problème vient du fait que j'utilise un proxy... (Lorsque je n'utilise pas de proxy, tout fonctionne correctement)
Après quelques recherches, j'ai essayé de résoudre le problème en ajoutant ces lignes dans le fichier "./google-api-php-client/src/Google/IO/Curl.php":
Code:
1 2 3
| curl_setopt($curl, CURLOPT_PROXYTYPE,CURLPROXY_HTTP);
curl_setopt($curl, CURLOPT_PROXY, "http://mon_proxy");
curl_setopt($curl, CURLOPT_PROXYPORT, mon_port); |
ou en essayant de modifier directement la fonction "setOptions()":
Code:
1 2 3 4 5 6
| public function setOptions($options)
{
$this->options[CURLOPT_PROXY] = 'http://mon_proxy';
$this->options[CURLOPT_PROXYPORT] = mon_port;
$this->options = $options + $this->options;
} |
Ca n'a pas fonctionné, j'ai toujours la même erreur, à savoir:
Code:
1 2 3 4 5 6 7 8
| 127.0.0.1:41696 [500]: /oauth2callback.php?code=4/uoEWBdMmSCF2So7nL4FXT2lHdrT9jPPfh0cEeeg3KVE - Uncaught exception 'Google_IO_Exception' with message 'HTTP Error: Unable to connect: 'fopen(https://accounts.google.com/o/oauth2/token): failed to open stream: Network is unreachable'' in /var/www/html/analytics-api/google-api-php-client/src/Google/IO/Stream.php:141
Stack trace:
#0 /var/www/html/analytics-api/google-api-php-client/src/Google/IO/Abstract.php(136): Google_IO_Stream->executeRequest(Object(Google_Http_Request))
#1 /var/www/html/analytics-api/google-api-php-client/src/Google/Auth/OAuth2.php(111): Google_IO_Abstract->makeRequest(Object(Google_Http_Request))
#2 /var/www/html/analytics-api/google-api-php-client/src/Google/Client.php(128): Google_Auth_OAuth2->authenticate('4/uoEWBdMmSCF2S...', false)
#3 /var/www/html/analytics-api/oauth2callback.php(19): Google_Client->authenticate('4/uoEWBdMmSCF2S...')
#4 {main}
thrown in /var/www/html/analytics-api/google-api-php-client/src/Google/IO/Stream.php on line 141 |
Pour info j'ai suivi ce tutoriel:
https://developers.google.com/analyt...kstart/web-php
Si quelqu'un a déjà rencontré ce problème ou si vous avez des idées, n'hésitez pas ! :)
Merci et bonne journée,
Johann