Last Updated: May 25, 2018
·
2.908K
· dhavaldave

PHP cURL custom headers

how to use PHP cURL custom headers

$ch = curlinit(); curlsetopt($ch, CURLOPTURL,"http://www.example.com/process.php"); curlsetopt($ch, CURLOPTPOST, 1); curlsetopt($ch, CURLOPTPOSTFIELDS,$vars); //Post Fields curlsetopt($ch, CURLOPTRETURNTRANSFER, true); $headers = [ 'X-Apple-Tz: 0', 'X-Apple-Store-Front: 143444,12', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'Accept-Encoding: gzip, deflate', 'Accept-Language: en-US,en;q=0.5', 'Cache-Control: no-cache', 'Content-Type: application/x-www-form-urlencoded; charset=utf-8', 'Host: www.example.com', 'Referer: http://www.example.com/index.php', //Your referrer address 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0', 'X-MicrosoftAjax: Delta=true' ]; curlsetopt($ch, CURLOPTHTTPHEADER, $headers); $serveroutput = curlexec ($ch); curlclose ($ch); print $server_output ; </code>

source@ http://www.onlinecode.org/