Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy cURL gives different output on server and localhost?
    primarykey
    data
    text
    <p>The below code gives different output on localhost and server. I tried changing useragents and browsers. Am I missing any header?</p> <pre><code>&lt;?php $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $headers[] = 'Accept-Language: en-us,en;q=0.5'; $headers[] = 'Accept-Encoding gzip,deflate'; $headers[] = 'Keep-Alive: 300'; $headers[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7'; //$headers[] = 'Content-Length: 0'; $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADERFUNCTION, 'dbg_curl_data'); curl_setopt($curl, CURLOPT_WRITEFUNCTION, 'dbg_curl_data'); curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7'); //curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11'); curl_setopt($curl, CURLOPT_URL, "http://www.facebook.com/login.php"); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); //curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_VERBOSE, 1); //curl_setopt($curl, CURLOPT_POST, true); $html = curl_exec ($curl); //curl_close ($curl); echo '&lt;fieldset&gt;&lt;legend&gt;request headers&lt;/legend&gt; &lt;pre&gt;', htmlspecialchars(curl_getinfo($curl, CURLINFO_HEADER_OUT)), '&lt;/pre&gt; &lt;/fieldset&gt;'; echo '&lt;fieldset&gt;&lt;legend&gt;response&lt;/legend&gt; &lt;pre&gt;', htmlspecialchars(dbg_curl_data(null)), '&lt;/pre&gt; &lt;/fieldset&gt;'; echo '&lt;fieldset&gt;&lt;legend&gt;$html&lt;/legend&gt; &lt;pre&gt;', htmlspecialchars($html), '&lt;/pre&gt; &lt;/fieldset&gt;'; function dbg_curl_data($curl, $data=null) { static $buffer = ''; if ( is_null($curl) ) { $r = $buffer; $buffer = ''; return $r; } else { $buffer .= $data; return strlen($data); } } ?&gt; </code></pre> <p>Output on Localhost : <a href="http://pastebin.com/UbpTVc4f" rel="nofollow">http://pastebin.com/UbpTVc4f</a></p> <p>Output on Server : <a href="http://pastebin.com/NURDksJy" rel="nofollow">http://pastebin.com/NURDksJy</a></p> <p>I want output as its on localhost.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload