healy
 1 <?php
 2 
 3 
 4 /*echo $_GET[\'echostr\'];
 5 exit;*/
 6 
 7 
 8 //接收xml数据
 9 $postStr = $GLOBALS[\'HTTP_RAW_POST_DATA\'];
10 //把xml数据转化成对象
11 $postObj = simplexml_load_string($postStr);
12 //接收post的值
13 $fromuserName = $postObj->FromUserName;
14 $touserName = $postObj->ToUserName;
15 $time = time();
16 $msgType = $postObj->MsgType;
17 $keywords = $postObj->Content;
18 
19 
20 //自动回复
21 $textTpl = "<xml>
22             <ToUserName><![CDATA[%s]]></ToUserName>
23             <FromUserName><![CDATA[%s]]></FromUserName>
24             <CreateTime>%s</CreateTime>
25             <MsgType><![CDATA[%s]]></MsgType>
26             <Content><![CDATA[%s]]></Content>
27             </xml>";
28 
29 //关键词自动回复
30 if($postObj->MsgType == "text" ){
31     if($postObj->Content == \'1\'){
32         $content = \'111!!!!\';
33         $resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
34         echo $resultful;
35     }else if($postObj->Content == \'2\'){
36 
37         $content = \'222!!!!\';
38         $resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
39         echo $resultful;
40     }else{
41         $content = \'hello world!\';
42         $resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
43         echo $resultful;
44         
45     }
46         
47     
48 }
49 
50 ?>

微信自动回复功能!

分类:

技术点:

相关文章:

  • 2022-01-07
  • 2021-09-09
  • 2021-12-16
  • 2021-10-29
  • 2021-12-15
  • 2021-12-14
猜你喜欢
  • 2021-11-11
  • 2021-10-29
  • 2021-10-29
  • 2021-10-19
  • 2021-11-30
  • 2021-05-09
相关资源
相似解决方案