user1775888
user1775888

Reputation: 3303

change location when file_get_contents

I use php file_get_contents to fetch a page from a location where people speak Chinese. I did test if I use browser directly to visit $path and the website detected my location and showed me this country's currency. Is it possible to let the browser think I am at united states? I tried send header like below but nothing change.

$opts = array(
        'http'=>array(
          'method' => "GET",
          'header' => "Accept-language: en\r\n" .
                      // "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20120306 Firefox/3.6.28 ( .NET CLR 3.5.30729; .NET4.0E)\r\n"
                      "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13\r\n"
        )
      );


$context = stream_context_create($opts);
$html = file_get_contents($path, false, $context);

Upvotes: 0

Views: 127

Answers (1)

fejese
fejese

Reputation: 4628

If the server that you want to load the page from detects your location by your IP you need to use a proxy. You can look for open proxies, or create one for yourself in AWS for example.

Upvotes: 2

Related Questions