1

I want to execute this code on local server. It gives the response, but when I try to run the same code on live stage server, it returns a 404 error.

$url = "http://www.google.com/search?q=saree&num=100&start=0&pws=0";
$name = $name;

$encoded = $url.$name;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, '111.119.226.129');
curl_setopt($ch, CURLOPT_PROXYPORT,'80');
curl_setopt($ch, CURLOPT_HEADER, 1);
$exec = curl_exec($ch);
curl_close ($ch);

I use random valid proxies for this code, and I'm sure the proxy is valid.

Can anyone help me please?

1
  • disable the server firewall will solve the problem Commented Jan 13, 2014 at 17:40

1 Answer 1

2

add these to your code and try

$url = "http://www.google.com/search?q=saree&num=100&start=0&pws=0";
$name = $name;

$encoded = $url.$name;
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
    curl_setopt($ch, CURLOPT_HEADER, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //set headers
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // set true for https urls
Sign up to request clarification or add additional context in comments.

1 Comment

you should try this code for finding errors. error_reporting(E_ALL); ini_set('display_errors', 1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.