Lamhot / php-google-map-api

Automatically exported from code.google.com/p/php-google-map-api
0 stars 0 forks source link

Work behind a proxy #24

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm working on a Ushahidi instance behind a proxy, and I was having problem 
getting the location of an adresss, finally I realise that the problem was on 
fetchURL.

The solution was to change from:

    function fetchURL($url) {

        return file_get_contents($url);

    }

To:

function fetchURL($url) {

        $context    = array(
            'http'  => array(
                'proxy'             => 'tcp://ip:port',
                'request_fulluri'   => true
            )
        );

        $context    = stream_context_create($context);

        return file_get_contents($url, False, $context);

    }

So would be important to have the chance to set a proxy and implement that 
solution.

Original issue reported on code.google.com by pedrofue...@gmail.com on 24 Nov 2010 at 3:13

GoogleCodeExporter commented 9 years ago
@ Pedrofue,

Thanks for this tip. I have a question: should I copy and paste as it is, or I 
have to provide the IP an Port numbers in the code above? Or before I even do 
this, my scenario is, Ushahidi installation on a PC we converted to a localhost 
server, but our network and internet are controlled my the organisation network 
infrastructure...is this the same scenario as yours, so that I can go ahead and 
do the you did?

Looking forward to your response, as I have struggled with the "Find Location" 
button in Ushahidi which keeps on processing and processing without zooming to 
the entered location.

Thanks.

Rodwell

Original comment by rtchire...@gmail.com on 13 May 2011 at 12:33

GoogleCodeExporter commented 9 years ago
you have to change:

tcp://ip:port

for the one that matchs your proxy configuration.

Original comment by pedrofue...@gmail.com on 14 May 2011 at 8:32

GoogleCodeExporter commented 9 years ago
Thanks Pedrofue. The code certainly works, however my Proxy is requesting 
authentication. Check what Firebug gave me below:

<h3>Warning Message</h3>
<p>An error was detected which prevented the loading of this page. If this 
problem persists, please contact the website administrator.</p>
<p><tt>C:/xampp/htdocs/ushahidi/application/libraries/GoogleMapAPI.php 
<strong>[2524]:</strong></tt></p>
<p><code 
class="block">file_get_contents(http://maps.google.com/maps/api/geocode/json?sen
sor=false&address=malakal) [<a 
href='function.file-get-contents'>function.file-get-contents</a>]: failed to 
open stream: HTTP request failed! HTTP/1.1 407 Proxy Authentication Required ( 
The ISA Server requires authorization to fulfill the request. Access to the Web 
P</code></p>

Any idea on Proxy authentication? I really appreciate your help, it makes me 
feel am closer to a solution.

Rodwell

Original comment by rtchire...@gmail.com on 30 May 2011 at 1:25

GoogleCodeExporter commented 9 years ago
And line 2524 is this one:

return file_get_contents($url, False, $context);

That's where the debugging points at.

Thanks

Original comment by rtchire...@gmail.com on 30 May 2011 at 1:31

GoogleCodeExporter commented 9 years ago
sorry for the quick answer, did you try:

tcp://username:password@ip:port

I don't know if that works didn't try it.

Original comment by pedrofue...@gmail.com on 30 May 2011 at 2:01

GoogleCodeExporter commented 9 years ago

Original comment by b...@mycnl.com on 25 Sep 2011 at 5:46