The PHP code follows the TP framework
Responsemsg (); }} Public Function responsemsg () {//get-post data, May is due to the different environments $postStr = $G lobals["Http_raw_post_data"]; $tmpstr = $POSTSTR; Libxml_disable_entity_loader (TRUE); $POSTOBJ = simplexml_load_string ($postStr, ' simplexmlelement ', libxml_nocdata); Extract post Data if (Strtolower ($postObj->msgtype) = = ' event ') {/* Libxml_disable_entity_loader is to prevent XML eXternal Entity injection, the best-of-the-is-check-the validity of XML by yourself */ if (strtolower ($postObj->event = = ' Subscribe ')) {$toUsername = $POSTOBJ->fr Omusername; $fromUsername = $POSTOBJ->tousername; $time = time (); $MsgType = ' text '; $content = "Welcome to my public number"; $TEXTTPL = "%s"; $info = sprintf ($TEXTTPL, $toUsername, $fromUsername, $time, $MsgTyPE, $content); Echo $info; } } }}
The test results are as follows:
Http://120.27.115.59/wechat.php/Home/Index/wechat success or failure: Decrypt fail! Error Reason: Xml fields error, please check your response xml! Status code: $ OK headers:cache-control:no-store, No-cache, Must-revalidate, post-check=0, pre-check=0connection: Keep-alivedate:tue, 10:23:34 gmtx-powered-by:php/5.5.9-1ubuntu4.14set-cookie:phpsessid= 4tlrj4jd7cgoo3ueaigc6753q7; path=/pragma:no-cacheserver:apache/2.4.7 (Ubuntu) Vary:accept-encodingexpires:thu, 1981 08:52:00 gmtcontent-type:text/htmlcontent-length:239 decryption before xml:1471947814 decrypted xml:
Reply content:
The PHP code follows the TP framework
Responsemsg (); }} Public Function responsemsg () {//get-post data, May is due to the different environments $postStr = $G lobals["Http_raw_post_data"]; $tmpstr = $POSTSTR; Libxml_disable_entity_loader (TRUE); $POSTOBJ = simplexml_load_string ($postStr, ' simplexmlelement ', libxml_nocdata); Extract post Data if (Strtolower ($postObj->msgtype) = = ' event ') {/* Libxml_disable_entity_loader is to prevent XML eXternal Entity injection, the best-of-the-is-check-the validity of XML by yourself */ if (strtolower ($postObj->event = = ' Subscribe ')) {$toUsername = $POSTOBJ->fr Omusername; $fromUsername = $POSTOBJ->tousername; $time = time (); $MsgType = ' text '; $content = "Welcome to my public number"; $TEXTTPL = "%s"; $info = sprintf ($TEXTTPL, $toUsername, $fromUsername, $time, $MsgTyPE, $content); Echo $info; } } }}
The test results are as follows:
Http://120.27.115.59/wechat.php/Home/Index/wechat success or failure: Decrypt fail! Error Reason: Xml fields error, please check your response xml! Status code: $ OK headers:cache-control:no-store, No-cache, Must-revalidate, post-check=0, pre-check=0connection: Keep-alivedate:tue, 10:23:34 gmtx-powered-by:php/5.5.9-1ubuntu4.14set-cookie:phpsessid= 4tlrj4jd7cgoo3ueaigc6753q7; path=/pragma:no-cacheserver:apache/2.4.7 (Ubuntu) Vary:accept-encodingexpires:thu, 1981 08:52:00 gmtcontent-type:text/htmlcontent-length:239 decryption before xml:1471947814 decrypted xml:
Solved the. Seems to be a TP problem.