php专区

 首页 > php专区 > PHP应用 > 开放平台 > 微信后台操作基础类管理 - 微信公众平台开发:

微信后台操作基础类管理 - 微信公众平台开发:

分享到:
【字体:
导读:
         [导读] ** * Created by PhpStorm * User: wym * Date: 15-3-18 * Time: 下午2:15 * class Wx_function{ var $FromUsername = null; var $ToUsername = null;...

/**
* Created by PhpStorm.
* User: wym
* Date: 15-3-18
* Time: 下午2:15
*/

class Wx_function{
  var $FromUsername = null;
  var $ToUsername = null;
  var $MsgType = null;
  var $Event = null;
  var $PicUrl = null;
  var $EventKey = null;
  var $Keyword = null;
  var $obj = null;

  function __construct(){
  //系构造赋值
    $postObj = simplexml_load_string($GLOBALS["HTTP_RAW_POST_DATA"], 'SimpleXMLElement', LIBXML_NOCDATA);
    $this->obj = $postObj;
    $this->FromUsername = $postObj->FromUserName;
    $this->ToUsername = $postObj->ToUserName;
    $this->EventKey = $postObj->EventKey; //
    $this->MsgType = $postObj->MsgType;
    $this->PicUrl = $postObj->PicUrl;
    $this->Event = $postObj->Event;
    $this->Keyword = trim($postObj->Content);
  }


  public function wxRequest($arr, $response){
    //不同类型直接封装
    $mssage = '';
    switch ($response) {
      case 'text' :
        $mssage = $this->wxGetText($arr);
        break;
      case 'news' :
        $mssage = $this->wxGetNews($arr);
        break;
      case 'voice':
        $mssage = $this->getVoice($arr);
      }
      //print_r($arr);
    return $mssage;
  }

  //事件处理
  public function wxEventRequest($Content, $response = 'text'){
    $mssage = '';
    switch ($this->MsgType) {
       case 'event':
         switch ($this->Event) {
           case 'subscribe' :
              switch ($response) {
                case 'text' :
                  $mssage = $this->wxGetText($Content);
                  break;
                case 'news' :
                  $mssage = $this->wxGetNews($Content);
                  break;
              }
              break;
          case 'unsubscribe' :
             break;
          }
      break;
    }
    return $mssage;
  }

}
分享到:
微风IM 3.3系列之三:客户端与服务器端通...
通信框架为networkcomms 2.3.1 使用TCP通信时,客户端端发送消息给服务器,比如 A消息是登陆消息 B消息是更新密码消息 服务器端如何区分A与B,并调用相应的处理器呢? NetworkComms通信框架采用这样的机制:  客户端为每个消息分派一个“消息类型”,服务器端根据“消息类型”,找到相应的处理器。 以“登陆消息”为例 ...
微信支付,使用证书时出现58错误 - 微信公...
  近期正在开发微信支付功能,用crul调用证书时提示类似错误   58 problem with the local client certificate.   经过查找手册和实验,参考php手册提供的以下方案可以解决,代码如下 If you want to connect to a server which requires that you identify yourself with a certificate, use following code...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……