您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
利用php的curl组装(自定义)请求头
发布时间:2017-04-28 09:38:33编辑:雪饮阅读()
$headers = array();
$headers[] = 'X-Apple-Tz: 0';
$headers[] = 'X-Apple-Store-Front: 143444,12';
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$headers[] = 'Accept-Encoding: gzip, deflate';
$headers[] = 'Accept-Language: en-US,en;q=0.5';
$headers[] = 'Cache-Control: no-cache';
$headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=utf-8';
$headers[] = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0';
$headers[] = 'X-MicrosoftAjax: Delta=true';
$headers[] = 'X-y:kv';//这个是自己自定义的
$curlstr="http://localhost/cs2.php";
$ch=curl_init();//初始化
curl_setopt($ch,CURLOPT_URL,$curlstr);//设置访问网页的URL
curl_setopt($ch,CURLOPT_RETURNTRANSFER,false);//执行之后不直接打印出来
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output=curl_exec($ch);//执行
curl_close($ch);
关键字词:php,curl,请求头
上一篇:php获取http请求头
下一篇:json_encode不转义