日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

微信公众号发多个消息php,微擎系统微信公众号关键字触发回复多条消息实现

發(fā)布時間:2025/3/20 php 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微信公众号发多个消息php,微擎系统微信公众号关键字触发回复多条消息实现 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1 private functionmsg_respond() {2 $rids = !is_array($this->rule) ? explode(‘,‘, $this->rule) : $this->rule;3 //數(shù)據(jù)庫中獲取發(fā)送文字的信息

4 $reply = table(‘basic_reply‘)->where(array(‘rid IN‘ => $rids))->orderby(‘id‘)->getAll();5 //圖片

6 $img_reply = table(‘images_reply‘)->where(array(‘rid IN‘ => $rids))->orderby(‘id‘)->getAll();7 //圖文8 //$news_reply = table(‘news_reply‘)->where(array(‘rid IN‘ => $rids,‘parent_id ==‘ => -1))->orderby(‘id‘)->getAll();

9 $news_reply = table(‘news_reply‘)->where(array(‘rid IN‘ => $rids))->orderby(‘id‘)->getAll();10 //音樂

11 $music_reply = table(‘music_reply‘)->where(array(‘rid IN‘ => $rids))->orderby(‘id‘)->getAll();12 //語音

13 $voice_reply = table(‘voice_reply‘)->where(array(‘rid IN‘ => $rids))->orderby(‘id‘)->getAll();14 //視頻

15 $video_reply = table(‘video_reply‘)->where(array(‘rid IN‘ => $rids))->orderby(‘id‘)->getAll();16 //父級找子級

17 /*foreach ($news_reply as &$value){18 //if ($value[‘parent‘] != -1) {19 $value[‘parent_data‘] = table(‘news_reply‘)->where([‘parent_id‘ => $value[‘id‘]])->orderby(‘id‘)->getAll();20 //}21 }*/

22

23 //判斷是否為空,如果都為空返回false

24 if (empty($reply)&&empty($img_reply)&&empty($news_reply)&&empty($music_reply)&&empty($voice_reply)&&empty($video_reply)) {25 return false;26 }27 $access_token=$this->getToken();28 $postStr=file_get_contents(‘php://input‘);29 $postObj = simplexml_load_string($postStr, ‘SimpleXMLElement‘,LIBXML_NOCDATA);30 if (count($reply)+count($img_reply)+count($news_reply)+count($music_reply)+count($voice_reply)+count($video_reply)==1){31 if($reply!=null){32 $reply[0][‘content‘] = htmlspecialchars_decode($reply[0][‘content‘]);33 $reply[0][‘content‘] = str_replace(array(‘
‘, ‘?‘), array("\n", ‘ ‘), $reply[0][‘content‘]);34 $reply[0][‘content‘] = strip_tags($reply[0][‘content‘], ‘‘);35 return $reply[0][‘content‘];36 }elseif ($img_reply!=null){37 for ($y=0;$yimageReply($postObj->FromUserName,$access_token,$img_reply[$y][‘mediaid‘]);39 }40 }elseif ($news_reply!=null){41 //$this->judgeType(‘news‘);

42 for ($j=0;$j

44 //$this->newsReply($postObj->FromUserName,$access_token,$news_reply[$j][‘url‘],$news_reply[$j][‘thumb‘],$news_reply[$j][‘title‘],$news_reply[$j][‘description‘],$news_reply[$j][‘parent_data‘]);

45 $this->newsReply($postObj->FromUserName,$access_token,$news_reply[$j][‘url‘],$news_reply[$j][‘thumb‘],$news_reply[$j][‘title‘],$news_reply[$j][‘description‘],$news_reply[$j][‘media_id‘]);46 }47 }elseif ($music_reply!=null){48 $result = $this->music_respond();49 return $this->respMusic(array(50 ‘Title‘ => $result[‘title‘],

51 ‘Description‘ => $result[‘description‘],

52 ‘MusicUrl‘ => $result[‘url‘],

53 ‘HQMusicUrl‘ => $result[‘hqurl‘],

54 ));55 }elseif ($voice_reply!=null){56 for ($s=0;$svoiceReply($postObj->FromUserName,$access_token,$voice_reply[$s][‘mediaid‘]);58 }59 }elseif ($video_reply!=null){60 for ($d=0;$dvideoReply($postObj->FromUserName,$access_token,$video_reply[$d][‘mediaid‘],$video_reply[$d][‘title‘],$video_reply[$d][‘description‘]);62 }63 }else{64 return "數(shù)據(jù)錯誤!!!";65 }66 }else{67 //循環(huán)發(fā)送圖片

68 for ($y=0;$yimageReply($postObj->FromUserName,$access_token,$img_reply[$y][‘mediaid‘]);70 }71 //循環(huán)發(fā)送圖文

72 for ($j=0;$jnewsReply($postObj->FromUserName,$access_token,$news_reply[$j][‘url‘],$news_reply[$j][‘thumb‘],$news_reply[$j][‘title‘],$news_reply[$j][‘description‘],$news_reply[$j][‘media_id‘]);74 }75 //視頻

76 for ($d=0;$dvideoReply($postObj->FromUserName,$access_token,$video_reply[$d][‘mediaid‘],$video_reply[$d][‘title‘],$video_reply[$d][‘description‘]);78 }79 //語音

80 for ($s=0;$svoiceReply($postObj->FromUserName,$access_token,$voice_reply[$s][‘mediaid‘]);82 }83 //循環(huán)發(fā)送文字

84 for($i=0;$ireplymsg($postObj->FromUserName,$access_token,trim($reply[$i][‘content‘]));89 }90 }91 }92 return 0;93 }

《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的微信公众号发多个消息php,微擎系统微信公众号关键字触发回复多条消息实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。