Basic class management for background operations *** CreatedbyPhpStorm. * User: wym * Date: 15-3-18 * Time: * classWx_function {var $ FromUsernamenull; var $ ToUsernamenull; var $ MsgT basic class management for background operations
/**
* Created by PhpStorm.
* User: wym
* Date: 15-3-18
* Time: PM
*/
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 (){
// Assign a value to the system structure
$ 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 types of 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 Processing
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;
}
}
Contact me for detailed source code