WeChat background Operation Basic class governance

Source: Internet
Author: User
Background Operations Foundation Class management

/**
* 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 () {
System Construction Assignment
$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) {
//different type direct encapsulation
$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;
}

Event handling
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;
}

}

Need detailed source of contact me

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.