I'm trying to load a remote website using the CURL request using proxies. I have pasted the below code in a PHP file and tried to run from my browser. It loads the remote URL, however, in the remote URL's statistics it's showing my local IP address!! Why it not showing the proxy IP?
Then I tried to run it using the cron tab. In this time, the remote website statistics is not showing anything?
In short: I want to load a remote website. But the remote website statistics tracker should show the proxy IP as well as the user agent I have specified in the code.
<?php
//debug
error_reporting(E_ALL);
ini_set('display_errors', 1);
//debug end
$url='http://www.example.com';
$agent = "Mozilla/5.0 (X11; U; Linux i686; en-US)
AppleWebKit/532.4 (KHTML, like Gecko)
Chrome/4.0.233.0 Safari/532.4";
$proxy = "104.236.203.134:8080";
$proxy = explode(':', $proxy);
$url = "http://google.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);
curl_setopt($ch, CURLOPT_HEADER, 1);
$exec = curl_exec($ch);
echo curl_error($ch);
print_r(curl_getinfo($ch));
echo $exec;
?>
Let me know what changes I should do to make it work as specified?