>  기사  >  php教程  >  WeChatCallBack.php框架基类实现

WeChatCallBack.php框架基类实现

WBOY
WBOY원래의
2016-06-06 19:43:30944검색

?php /** * *wechat basic callback * **/ require_once dirname(__FILE__) . '/../common/GlobalDefine.php' ; class WeChatCallback { protected $_postObject; protected $_fromUserName; protected $_toUserName; protected $_createTime; protected $_m

/**

*

*wechat basic callback

*

**/

 

require_once dirname(__FILE__)  .   '/../common/GlobalDefine.php' ;

 

class WeChatCallback {

    protected $_postObject;

    protected $_fromUserName;

    protected $_toUserName;

    protected $_createTime;

    protected $_msgType;

    protected $_msgId;

    protected $_time;

    pubilc function getToUserName() {

      return $this->_toUserName;

    }

    // 组装提示信息,HINT_TPL在GlobalDefine.php中定义

    protected function init($postObj) {

      $resultStr = sprintf ( HINT_TPL, $this->_fromUserName,

      $this->_toUserName,&this->_time, 'text', $hint ) ;

      return $resultStr;

    }

 

    pubilc function init($postObj) {

      // 获取参数

      $this->_postObject = $postObj;

      if ($this->_postObject == false) {

        return false;

      }

      $this->_fromUserName = ( string ) trim ( $ this->_postObject->FromUserName );

      $this->_createTime = ( int ) trim ( $this->_postObject->MsgId );

      $this->_time = time ();

      if(!($this->_fromUserName && $this->_toUserName && $this->_msgType)) {

        return false;

      }

      return true;

    }

 

    public function process() {

      // HINT_NOT_IMPLEMEMT在GlobalDefine.php中定义的一个提示信息

      return $this->makeHint (HINT_NOT_IMPLEMEMT) ;

    }

}

?>

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.