Showing posts with label How to use proxy server in PHP. Show all posts
Showing posts with label How to use proxy server in PHP. Show all posts

Saturday, May 14, 2011

Use proxy server in PHP

How to use proxy server in PHP.

<?php
// First get the Free proxy list from here
// http://hidemyass.com/proxy-list/search-284460

set_time_limit(0) ;
$t1=time();
$urltopost = "http://amitkgaur.blogspot.com/";

// $urltopost = http://www.xyz.com/t3resultpage.aspx?type=p=test1&q=test2&rid=7851
// $datatopost = array (
//  "firstname" => "Amit",
// "lastname" => "Gaur",
// "blog" => "http://amitkgaur.blogspot.com/",
// );

 $crl = curl_init ($urltopost);
 curl_setopt ($crl, CURLOPT_POST, true);
 curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($crl, CURLOPT_PROXY, "115.248.234.254:3128");
 curl_setopt($crl, CURLOPT_PROXYPORT, 3128); 
 //curl_setopt ($crl, CURLOPT_POSTFIELDS, $datatopost);
 curl_setopt ($crl, CURLOPT_RETURNTRANSFER, true);
 $ans = curl_exec ($crl);
 $t2=time();
 $lapsed=$t2-$t1;
 echo "<br/>Total time taken" . $lapsed;
 echo $ans;
?>