PHP curl cannot read a page -


php curl @ our localhost works fine not on other server

here code

$ch = curl_init(); curl_setopt($ch, curlopt_useragent, "mozilla/5.0 (x11; ubuntu; linux i686; rv:13.0) gecko/20100101 firefox/13.0.1" ); curl_setopt($ch, curlopt_url, 'http://50.7.243.50:8054/played.html'); curl_setopt($ch, curlopt_post, 0); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_header ,0); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch,curlopt_timeout,120); curl_setopt($ch,curlopt_maxredirs,20); $data = curl_exec ($ch); if ($data == false) echo "curl error : ".curl_error($ch)."<br>"; curl_close ($ch); 

even if

curl_setopt($ch, curlopt_url, 'http://50.7.243.50/played.html'); curl_setopt($ch, curlopt_port, 8054); 

it shows error couldn't connect host

any appreciated....

try code, have tested , working.

$html = "http://50.7.243.50:8054/played.html"; $header = array(); $header[] = 'accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'; $header[] = 'cache-control: max-age=0'; $header[] = 'connection: keep-alive'; $header[] = 'keep-alive: 300'; $header[] = 'accept-charset: iso-8859-1,utf-8;q=0.7,*;q=0.7'; $header[] = 'accept-language: en-us,en;q=0.5'; $header[] = 'pragma: '; $ch = curl_init(); $proxy_ip = '122.72.112.148'; $proxy_port = 80; curl_setopt($ch, curlopt_proxyport, $proxy_port); curl_setopt($ch, curlopt_proxytype, 'http'); curl_setopt($ch, curlopt_proxy, $proxy_ip); curl_setopt($ch, curlopt_url, $html); curl_setopt ($ch, curlopt_port , 8054); curl_setopt($ch, curlopt_useragent, 'mozilla/5.0 (windows; u; windows nt 6.0; en-us; rv:1.9.0.11) gecko/2009060215 firefox/3.0.11 (.net clr 3.5.30729)'); curl_setopt($ch, curlopt_httpheader, $header); curl_setopt($ch, curlopt_autoreferer, true); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_encoding, ''); curl_setopt($ch, curlopt_timeout, 20); $result = curl_exec($ch); curl_close ($ch); echo $result; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -