最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP基于curl實(shí)現(xiàn)模擬微信瀏覽器打開微信鏈接的方法示例

 更新時(shí)間:2019年02月15日 10:40:14   作者:無顛  
這篇文章主要介紹了PHP基于curl實(shí)現(xiàn)模擬微信瀏覽器打開微信鏈接的方法,結(jié)合實(shí)例形式分析了php使用curl通過設(shè)置HTTP_USER_AGENT實(shí)現(xiàn)模擬微信瀏覽器相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP基于curl實(shí)現(xiàn)模擬微信瀏覽器打開微信鏈接的方法。分享給大家供大家參考,具體如下:

網(wǎng)絡(luò)上沒有可以直接打開微信的瀏覽器 但是我們可以模擬瀏覽器

微信瀏覽器的HTTP_USER_AGENT

在iPhone下,返回

Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2

在Android下,返回

Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255

不難發(fā)現(xiàn)微信瀏覽器為 MicroMessenger ,并且有版本號(hào),也可以判斷手機(jī)類型為iPhone還是Android

php 模擬 微信瀏覽器 使用如下:

get 方式

function get($url, $referer, $cookie) {
  $header = array();
  $header[] = 'Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*';
  $header[] = 'Connection: Keep-Alive';
  $header[] = 'Accept-Language: zh-cn';
  $header[] = 'Cache-Control: no-cache';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2');
  curl_setopt($ch, CURLOPT_REFERER, $referer);
  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  $result = curl_exec($ch);
  curl_close($ch);
  return $result;
}
echo get('http://wxt.wedoor.com/wxtAction.do?method=showyl&id=f20c503cac9349308c3a87ecbae5908c&scene=1','','');

post方式

function post($url, $data, $referer, $cookie) {
  $header = array();
  $header[] = 'Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*';
  $header[] = 'Connection: Keep-Alive';
  $header[] = 'Accept-Language: zh-cn';
  $header[] = 'Cache-Control: no-cache';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255');
  curl_setopt($ch, CURLOPT_REFERER, $referer);
  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  $result = curl_exec($ch);
  curl_close($ch);
  return $result;
}
echo post('http://wxt.wedoor.com/wxtAction.do?method=showyl&id=f20c503cac9349308c3a87ecbae5908c&scene=1','','','');

如此這般就可以了

如果要做盜鏈

if(strpos($_SERVER["HTTP_USER_AGENT"],"MicroMessenger"))
  echo "Welcome to wechat word";
else
  echo "http/1.1 401 Unauthorized";

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php curl用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》及《PHP中json格式數(shù)據(jù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

祁门县| 新建县| 贵德县| 武隆县| 东兴市| 永顺县| 余江县| 福清市| 依安县| 和平县| 资中县| 蒙自县| 沙洋县| 宿迁市| 芷江| 西林县| 蒙城县| 沁源县| 陕西省| 溧阳市| 玉溪市| 明水县| 原平市| 濮阳县| 高台县| 万盛区| 彭泽县| 绵阳市| 紫云| 营口市| 拜泉县| 区。| 萝北县| 开封县| 临漳县| 内黄县| 江安县| 南郑县| 同德县| 宁蒗| 巨鹿县|