PHP7中文手册2018 带注释 最新chm版
微信调用官方的代码,但是不知道为何用客户端还是官方的测试api用户都无法收到信息
查阅好多,终于找到解决方法了
$postStr = $GLOBALS ["HTTP_RAW_POST_DATA"];
$postStr = file_get_contents("php://input");//因为很多都设置了register_globals禁止,不能用$GLOBALS["HTTP_RAW_POST_DATA"];
下面附上测试好的代码
this->_helper->viewRenderer->setNoRender (); //get post data, May be due to the different environments //$postStr = $GLOBALS ["HTTP_RAW_POST_DATA"]; $postStr = file_get_contents("php://input"); //extract post data if (! empty ( $postStr )) { $postObj = simplexml_load_string ( $postStr, 'SimpleXMLElement', LIBXML_NOCDATA ); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim ( $postObj->Content ); $time = time (); $textTpl = ""; if (! empty ( $keyword )) { $msgType = "text"; $contentStr = "Welcome to wechat world!"; $resultStr = sprintf ( $textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr ); echo $resultStr; } else { echo "Input something..."; } } else { echo "apibug Input something..."; exit (); } } %s 0
转载请注明:谷谷点程序 » 微信公共平台php收不到信息解决方法