jamzgoodguy / google-api-php-clientsatuh

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

Add support for using a proxy #368

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try any of the examples
2. Fail when using the code behind an HTTP/HTTPS proxy

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

0.6.5, Ubuntu 12.04, 64bit

Please provide any additional information below.

Original issue reported on code.google.com by jesus.ca...@gmail.com on 12 Aug 2013 at 9:29

GoogleCodeExporter commented 8 years ago
am also trying to have proxy in curlio file but it is throwing out error.

Original comment by as885...@gmail.com on 27 Aug 2013 at 5:55

GoogleCodeExporter commented 8 years ago
Could you paste in an example of the code you're using and the error displayed? 

Original comment by ianbar...@google.com on 27 Aug 2013 at 2:44

GoogleCodeExporter commented 8 years ago
Just before the $ch = curl_init(); in function makeRequest() in 
Google_CurlIO.php, add these four lines to solve this issue:

curl_setopt($ch,CURLOPT_PROXYTYPE,CURLPROXY_HTTP);
curl_setopt($ch,CURLOPT_PROXY,$ProxyURL);
curl_setopt($ch,CURLOPT_PROXYPORT,$ProxyPort);
curl_setopt($ch,CURLOPT_PROXYUSERPWD,$ProxyUser);

Cédric

Original comment by cedric.clement@gmail.com on 29 Aug 2013 at 8:38

GoogleCodeExporter commented 8 years ago
You can do that with the setOptions method on CurlIO, no need to modify the 
class itself. 

Original comment by ianbar...@google.com on 29 Aug 2013 at 10:10

GoogleCodeExporter commented 8 years ago
Right, sorry...

Original comment by cedric.clement@gmail.com on 29 Aug 2013 at 12:52

GoogleCodeExporter commented 8 years ago
However, if the proxy add some http headers, you have to modify the makeRequest 
method in order to get a correct JSON string via getResponseBody method, for 
example (ugly) :
$respHeaderSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE) + 110;
where 110 match the length of added headers...

Original comment by cedric.clement@gmail.com on 29 Aug 2013 at 1:51

GoogleCodeExporter commented 8 years ago
A little bit smarter modifying the method authenticate in Google_OAuth2.php :
$ResponseBody = $request->getResponseBody();
$this->setAccessToken(substr($ResponseBody,strpos($ResponseBody,'{')));

Original comment by cedric.clement@gmail.com on 29 Aug 2013 at 2:14

GoogleCodeExporter commented 8 years ago
Looks like the header offset is being resolved in libcurl, which will fix 
CURLINFO_HEADER_SIZE: https://github.com/bagder/curl/pull/60

Original comment by ianbar...@google.com on 30 Aug 2013 at 12:08

GoogleCodeExporter commented 8 years ago
You are right. The update from libcurl 7.24 to 7.30 (via the update of 
considered PHP extension) solve the issue and patches in the code (curl and 
rest) are not usefull anymore. Thanks a lot.
Cédric

Original comment by cedric.clement@gmail.com on 31 Aug 2013 at 12:14