久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP實(shí)現(xiàn)登陸并抓取微信列表中最新一組微信消息的方法

這篇文章主要介紹了PHP實(shí)現(xiàn)登陸并抓取微信列表中最新一組微信消息的方法,涉及php針對微信接口的登陸、抓取、轉(zhuǎn)換等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP實(shí)現(xiàn)登陸并抓取微信列表中最新一組微信消息的方法。分享給大家供大家參考,具體如下:

<?php
$_G['wx_g'] = array('init' => array(
        "wx_content" => array("weixin_user" => "微信號碼", "weixin_pass" => "微信密碼")
      )
);
wx_login();
$messge_list = get_message_list();
$file_id=$messge_list['item'][0]['multi_item'][0]['file_id'];
//print_r($messge_list);exit;
if(!DB::result_first("select count(weiyi_id) from test.yangang_jiaojing where weiyi_id={$file_id} ")){
  DB::query("delete from test.yangang_jiaojing");
  foreach ($messge_list['item'][0]['multi_item'] as $key => $val){
      $val['title']=mb_convert_encoding($val['title'], 'GBK','UTF-8');
      $val['weiyi_id']=mb_convert_encoding($val['file_id'], 'GBK','UTF-8');
      $val['des']=mb_convert_encoding($val['digest'], 'GBK','UTF-8');
      $val['picurl']=$val['cover'];
      $val['detail']=$val['content_url'];
      $query_cheng = "INSERT INTO test.yangang_jiaojing(weiyi_id,title,pic_url,detail_url,des)VALUES ({$val['weiyi_id']},'{$val['title']}','{$val['picurl']}','{$val['detail']}','{$val['des']}')";
      $count1=DB::query($query_cheng);
  }
}
function get_message_list(){
  global $_G;
  $cookie=$_G['wx_g']['cookie'];
  $url = "https://mp.weixin.qq.com/cgi-bin/appmsg?begin=0&count=2&t=media/appmsg_list&type=10&action=list&token=".$_G['wx_g']['token']."&lang=zh_CN";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  curl_setopt($ch, CURLOPT_REFERER, "https://mp.weixin.qq.com/cgi-bin/appmsg?begin=0&count=2&t=media/appmsg_list&type=10&action=list&token=".$_G['wx_g']['token']."&lang=zh_CN");
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch, CURLOPT_SSLVERSION, 3);
  $output2 = curl_exec($ch);
  curl_close($ch);
  //echo $output2;exit;
  $output1=explode('wx.cgiData = ',$output2);
  $output1=$output1[1];
  $output1=explode(',"file_cnt":',$output1);
  $output1=$output1[0];
  $output1.='}';
  $message_list=json_decode($output1,true);
  //$message_list=mb_convert_encoding($message_list, "GBK","UTF-8");
  //print_r($message_list);exit;
  return $message_list;
}
function wx_login(){
  global $_G;
  //echo $_G['wx_g']['init']['wx_content']['weixin_user'];exit;
  $username = $_G['wx_g']['init']['wx_content']['weixin_user'];
  $pwd = md5($_G['wx_g']['init']['wx_content']['weixin_pass']);
  $url = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
  $post_data = "username=".$username."&pwd=".$pwd."&imgcode=&f=json";
  $cookie = "pgv_pvid=2067516646";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  curl_setopt($ch, CURLOPT_REFERER, "https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN");
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch, CURLOPT_SSLVERSION, 3);
  $output = curl_exec($ch);
  curl_close($ch);
  //echo $output;exit;
  list($header, $body) = explode("\r\n\r\n", $output);
  preg_match_all("/set\-cookie:([^\r\n]*)/i", $header, $matches);
  if(!empty($matches[1][2])){
    $cookie = $matches[1][0].$matches[1][1].$matches[1][2].$matches[1][3];
  }else{
    $cookie = $matches[1][0].$matches[1][1];
  }
  $cookie = str_replace(array('Path=/',' ; Secure; HttpOnly','=;'),array('','','='), $cookie);
  $cookie = 'pgv_pvid=6648492946;'.$cookie;
  $data = json_decode($body,true);
  $result = explode('token=',$data['redirect_url']);
  $token = $result[1];
  if(!$token) cpmsg($installlang['import_error_password'], "{$request_url}&step=import&pswerror=1", 'error');
  //寫入到全局變量
  $_G['wx_g']['cookie'] = $cookie;
  $_G['wx_g']['token'] = $token;
}
?>

CREATE TABLE IF NOT EXISTS `yangang_jiaojing` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `title` varchar(100) NOT NULL,
 `des` varchar(300) NOT NULL,
 `detail_url` varchar(300) NOT NULL,
 `pic_url` varchar(300) NOT NULL,
 `note` varchar(50) NOT NULL,
 `weiyi_id` int(11) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=gbk AUTO_INCREMENT=1 ;

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP微信開發(fā)技巧匯總》、《PHP編碼與轉(zhuǎn)碼操作技巧匯總》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語法入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》

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

【網(wǎng)站聲明】本站除付費(fèi)源碼經(jīng)過測試外,其他素材未做測試,不保證完整性,網(wǎng)站上部分源碼僅限學(xué)習(xí)交流,請勿用于商業(yè)用途。如損害你的權(quán)益請聯(lián)系客服QQ:2655101040 給予處理,謝謝支持。

相關(guān)文檔推薦

這篇文章主要介紹了PHP有序表查找之插值查找算法,簡單分析了插值查找算法的概念、原理并結(jié)合實(shí)例形式分析了php實(shí)現(xiàn)針對有序表插值查找的相關(guān)操作技巧,需要的朋友可以參考下
下面小編就為大家分享一篇ThinkPHP整合datatables實(shí)現(xiàn)服務(wù)端分頁的示例代碼,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
下面小編就為大家分享一篇PHP實(shí)現(xiàn)APP微信支付的實(shí)例講解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
這篇文章主要介紹了PHP實(shí)現(xiàn)的多維數(shù)組排序算法,結(jié)合實(shí)例形式對比分析了php針對多維數(shù)組及帶有鍵名的多維數(shù)組進(jìn)行排序相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下
這篇文章主要為大家詳細(xì)介紹了php結(jié)合ajaxuploadfile實(shí)現(xiàn)無刷新文件上傳功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本篇文章給大家詳細(xì)介紹了PHP開發(fā)接口使用RSA進(jìn)行加密解密方法,對此有興趣的朋友可以學(xué)習(xí)下。
主站蜘蛛池模板: 亚洲国产精品人人爽夜夜爽 | 亚洲欧美日韩精品久久亚洲区 | 国产特一级黄色片 | 欧美三区在线观看 | 中文日本在线 | 婷婷五月色综合香五月 | 天天射天天干 | 亚洲一区二区三区免费 | 成人影院在线视频 | 欧美激情一区二区 | 欧美精品在线免费观看 | 一区二区三区电影网 | 国产午夜精品一区二区三区在线观看 | 亚洲欧美日韩精品久久亚洲区 | 99久久婷婷国产综合精品电影 | 日韩欧美三区 | 色屁屁在线观看 | 新疆少妇videos高潮 | 91视频网址 | 亚洲电影一级片 | 99九色| 久久久久国产一区二区三区 | 天天综合成人网 | 亚洲综合大片69999 | 黑人巨大精品欧美一区二区一视频 | 羞羞免费网站 | 久久久免费精品 | 国产高清一区二区三区 | 国产在线中文字幕 | 日本视频在线 | 国产激情在线观看视频 | 日韩在线中文字幕 | 色婷婷精品国产一区二区三区 | 亚洲成av人片在线观看 | 一区二区高清 | 婷婷成人在线 | 日韩成人免费av | 黄色毛片免费看 | 国产精品久久一区二区三区 | 成人性视频在线 | 日韩一二区 |