亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》
  • 首頁 > 
  • 教程 > 
  • 開發技術 > 
  • PHP如何使用微信開發模式實現搜索已發送圖文及匹配關鍵字回復

PHP如何使用微信開發模式實現搜索已發送圖文及匹配關鍵字回復

發布時間:2021-07-26 14:52:32 來源:億速云 閱讀:95 作者:小新 欄目:開發技術

這篇文章將為大家詳細講解有關PHP如何使用微信開發模式實現搜索已發送圖文及匹配關鍵字回復,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

具體如下:

用戶發送關鍵字,搜索相應的圖文進行回復。

模擬登陸就不說了

右鍵看“已發送”圖片頁的源代碼,圖文部分是json格式的。

{"msg_item":[{"id":80630,"type":9,"fakeid":"2397007301","nick_name":"每天學點心理學","date_time":1403445168,"content":"","source":"mass","msg_status":2,"title":"(第167期)| 我讀過的具有正能量的一篇文章,為你取暖","desc":"傳說世間的一切生靈皆可修煉成仙,而貓自然在其中。每修煉二十年,貓就會多長出一條尾巴,等到有...","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201393381&idx=1&sn=5351cb8d440365c24a6abb709e4e0d8c#rd","show_type":1,"file_id":201393328,"app_sub_type":3,"comment_url":"","has_reply":0,"refuse_reason":"","multi_item":[{"seq":0,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/jOtiajqZ1n62uicM0XBZkqUB5BdJRdCMt0Y3CDIApNglh7Lj5zcmfm0mqN0YyGkNvekxP7j0uqs95AQejwZpTfCg\/0","title":"(第167期)| 我讀過的具有正能量的一篇文章,為你取暖","digest":"傳說世間的一切生靈皆可修煉成仙,而貓自然在其中。每修煉二十年,貓就會多長出一條尾巴,等到有...","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201393381&idx=1&sn=5351cb8d440365c24a6abb709e4e0d8c#rd","file_id":201393328,"content":"","source_url":"","author":"","show_cover_pic":0,"vote_id":[]}],"to_uin":0,"send_stat":{"total":1656,"succ":1656,"fail":0}},{"id":80444,"type":2,"fakeid":"2397007301","nick_name":"每天學點心理學","date_time":1403358199,"source":"mass","msg_status":2,"comment_url":"","has_reply":0,"refuse_reason":"","multi_item":[],"to_uin":0,"send_stat":{"total":1631,"succ":1631,"fail":0}},{"id":80222,"type":9,"fakeid":"2397007301","nick_name":"每天學點心理學","date_time":1403272191,"content":"","source":"mass","msg_status":2,"title":"(第166期)| 想要的超能力,來玩一個投票娛樂下吧~","desc":"雖然沒啥了不起的,但還是想要的這種超能力…-----------END-----------可以點擊右上角『","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201376620&idx=1&sn=a9ccae0826f5aa74476dc5936cec51f2#rd","show_type":1,"file_id":201370866,"app_sub_type":3,"comment_url":"","has_reply":0,"refuse_reason":"","multi_item":[{"seq":0,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/jOtiajqZ1n62MibMmurxXEVsDbwZglIq1wSxian2K6cH8Du0l3fMgQ2GdmbovicAXpSmjslI9iaCXicCTJC5Mef8ggBA\/0","title":"(第166期)| 想要的超能力,來玩一個投票娛樂下吧~","digest":"雖然沒啥了不起的,但還是想要的這種超能力…-----------END-----------可以點擊右上角『","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201376620&idx=1&sn=a9ccae0826f5aa74476dc5936cec51f2#rd","file_id":201370866,"content":"","source_url":"","author":"","show_cover_pic":0,"vote_id":[45050]},{"seq":1,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/jOtiajqZ1n62MibMmurxXEVsDbwZglIq1w4hNsMaia4p6SXGIUU6NBwbyEbpFL2mESOJ0yuP5pJhzavHzgnyPMM1A\/0","title":"【美文】| 揮之不去的無奈","digest":"躺在床上,過往的一幕幕在腦海掠過。四年的堅持,抑或說是7年的夢想,當它破滅時,僅僅淡然一笑,談何容易?其實行","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201376620&idx=2&sn=21a7f8715f4b2ecc2f484fd3b04ca554#rd","file_id":201371031,"content":"","source_url":"","author":"","show_cover_pic":1,"vote_id":[]},{"seq":2,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/jOtiajqZ1n62MibMmurxXEVsDbwZglIq1wNzqasiaEPYAGXQQdLnkaiaW56ueicHelZFJCjWUA3dg6ibWw15N1KQtEeQ\/0","title":"【插畫】| 不是所有的傷口都能自我愈合","digest":"愿每一個相信愛的女生,都能成為愛里打不倒的戰士。沒有人比你更美好,因為這個世界上不會再有第二個你了。少一點依","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201376620&idx=3&sn=ca0a2122e1c5d8f848fd6412ea347664#rd","file_id":201374122,"content":"","source_url":"","author":"","show_cover_pic":0,"vote_id":[]}],"to_uin":0,"send_stat":{"total":1610,"succ":1610,"fail":0}},{"id":79872,"type":1,"fakeid":"2397007301","nick_name":"每天學點心理學","date_time":1403185708,"content":"朋友們,今天休息,不發咯,你們也早點休息喲?\/:<L>","source":"mass","msg_status":2,"comment_url":"","has_reply":0,"refuse_reason":"","multi_item":[],"to_uin":0,"send_stat":{"total":1584,"succ":1584,"fail":0}},{"id":79544,"type":9,"fakeid":"2397007301","nick_name":"每天學點心理學","date_time":1403098674,"content":"","source":"mass","msg_status":2,"title":"(第165期)| 孩子為什么會偷東西","desc":"小孩偷東西是一種很嚴重的行為,但好像是很多孩子在成長過程中都有偷東西一個階段,父母該如何教育呢?孩子為什么會","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201345041&idx=1&sn=b2ef53dcfd93db2737240f932a0297d5#rd","show_type":1,"file_id":201240144,"app_sub_type":3,"comment_url":"","has_reply":0,"refuse_reason":"","multi_item":[{"seq":0,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/jOtiajqZ1n60ZFQ7comgKCEXlkibVZXmJf1PqAs4czgl0AiakwonBibD5DT2ytE6tA8VJdBVibuS92XgWXbuMibKmicRg\/0","title":"(第165期)| 孩子為什么會偷東西","digest":"小孩偷東西是一種很嚴重的行為,但好像是很多孩子在成長過程中都有偷東西一個階段,父母該如何教育呢?孩子為什么會","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201345041&idx=1&sn=b2ef53dcfd93db2737240f932a0297d5#rd","file_id":201240144,"content":"","source_url":"","author":"蟲子","show_cover_pic":1,"vote_id":[]},{"seq":1,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/jOtiajqZ1n60ZFQ7comgKCEXlkibVZXmJfRPJl3P72Vh8l46B1m6EvZY4IWRnFB0AHkxrTSbghME9TxmFyibbxXdQ\/0","title":"八張圖讓你明白很多","digest":"小圖片,大道理。-----------END-----------可以點擊右上角『分享至朋友圈』。微信號:m","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MjM5NzAwNzMwMQ==&mid=201345041&idx=2&sn=63ae37b620566f2dc80d4b229b98a5f4#rd","file_id":201240187,"content":"","source_url":"","author":"蟲子","show_cover_pic":0,"vote_id":[]}],"to_uin":0,"send_stat":{"total":1568,"succ":1568,"fail":0}}]}

直接解析json即可。

<?php
$wechatObj = new wechatappmsg();
$wechatObj->getappmsg('這里是json');
class wechatappmsg{
  function getappmsg($content){
    //require_once 'db.php';
    $jsonstr=$content;
    //   $jsonstr='{"msg_item":[{"id":79544,"type":9},{}]}';
    $jsonstr = iconv('gbk', 'utf-8', $jsonstr);
    $result = json_decode($jsonstr);
    $name=$result->msg_item;
    // var_dump($name);
    //   echo '<br/>json:'.$result;
    $size=count($name);
    echo '<br/>size:'.$size;
    //  exit;
    for($i=0;$i<$size;$i++){
      $multi_item=$name[$i]->multi_item;
      $size2=count($multi_item);
      $app_id=$name[$i]->app_id;
      $create_time=$name[$i]->date_time;//發送時間
      //  echo '<br/>app_id:'.$app_id;
      $create_time=date ("Y-m-d H:i:s", $create_time);//時間轉換
      echo '<br/>create_time:'.$create_time;
      for($j=0;$j<$size2;$j++){
        $title=$multi_item[$j]->title;//標題
        $pic_url=$multi_item[$j]->cover;//圖片地址
        $digest=$multi_item[$j]->digest;//簡要
        $content_url=$multi_item[$j]->content_url;//圖文地址
        $t = iconv('utf-8', 'gbk', $title);
        echo '<br/>title:'.$t;
        echo '<br/>Link:'.$content_url;
        preg_match("/mid=([0-9]+)&/",$content_url,$string);
        $app_mid=$string[1];//一次發送的多個圖文,這個ID值可以判斷這兩個圖文是同一次發送的
        echo '<br/>app_mid:'.$app_mid;
        //這里可以直接進行入庫
//$x=saveappmsg($pic_url,$title,$digest,$content_url,$create_time,$app_mid);
 sleep(3);
      }
      echo '<br/>-------------------------------------';
    }
  }
}
?>

數據庫:

PHP如何使用微信開發模式實現搜索已發送圖文及匹配關鍵字回復

用戶回復關鍵字,然后查詢回復相應圖文信息。

1》根據期數進行查詢:

select app_id from table where title like '%162期%' limit 1;
select * from table where app_id=XXXXX;

2》根據關鍵字:

select * from table where title like '%故事%' limit 10;

PHP如何使用微信開發模式實現搜索已發送圖文及匹配關鍵字回復

關于“PHP如何使用微信開發模式實現搜索已發送圖文及匹配關鍵字回復”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

php
AI

定陶县| 阳东县| 玉溪市| 贵州省| 集安市| 东辽县| 库尔勒市| 炎陵县| 登封市| 房产| 万年县| 兰溪市| 板桥市| 建平县| 广州市| 柞水县| 左权县| 全南县| 乐昌市| 汉中市| 科尔| 夏河县| 武宣县| 千阳县| 安西县| 固阳县| 沧州市| 定襄县| 彰化市| 隆昌县| 德江县| 咸宁市| 宿迁市| 广西| 金沙县| 金乡县| 铁力市| 赤城县| 色达县| 铜鼓县| 渭南市|