gpt4 book ai didi

PHP使用微信开发模式实现搜索已发送图文及匹配关键字回复的方法

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 30 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章PHP使用微信开发模式实现搜索已发送图文及匹配关键字回复的方法由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

本文实例讲述了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\/jotiajqz1n62uicm0xbzkqub5bdjrdcmt0y3cdiapnglh6lj5zcmfm0mqn0yygknvekxp7j0uqs95aqejwzptfcg\/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即可。

  。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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》根据期数进行查询:

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

2》根据关键字:

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

PHP使用微信开发模式实现搜索已发送图文及匹配关键字回复的方法

希望本文所述对大家php程序设计有所帮助.

原文链接:http://blog.csdn.net/macwhirr123/article/details/33739685 。

最后此篇关于PHP使用微信开发模式实现搜索已发送图文及匹配关键字回复的方法的文章就讲到这里了,如果你想了解更多关于PHP使用微信开发模式实现搜索已发送图文及匹配关键字回复的方法的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com