Example #1
0
 $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
 //post 原始数据
 $msg = $api->getCallMsg($postStr);
 //解析xml
 /**
  * 返回为 object : { type: "微信类型",
  *                  keyword:"用户输入的字符串“,
  *                  event: "微信事件类型"
  *                  fromUserName: "******"
  *                  toUserName: "******"
  *                  xmlObj: 解析的完整结果
  *                  }
  * 如果 返回false 表示数据不能解析
  **/
 if ($msg == false) {
     echo $api->responseText("红包出错了");
     exit;
 }
 $type = $msg->type;
 if ($type == "event") {
     $event = $msg->event;
     switch ($event) {
         case "subscribe":
             //关注事件
             echo $api->responseText("敬请期待红包哟!");
             break;
     }
     exit;
 } else {
     if ($type == "text") {
         $keyword = $msg->keyword;