function responseMsg() { //get post data, May be due to the different environments //$postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; $postStr = file_get_contents("php://input"); log_file("postStr:" . $postStr); //extract post data if (!empty($postStr)) { /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection, the best way is to check the validity of xml by yourself */ libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); // $msgType = trim($postObj->MsgType); log_file("msgType:{$msgType}"); switch ($msgType) { case "text": $resultStr = handleText($postObj); break; case "event": $resultStr = handleEvent($postObj); break; case "video": $resultStr = handleVideo($postObj); break; case "voice": $resultStr = handleVoice($postObj); break; case "image": $resultStr = handleImage($postObj); break; default: $resultStr = response_text($postObj, ""); break; } echo $resultStr; } else { echo ""; exit; } }
function responseMsg() { $postStr = file_get_contents("php://input"); log_file("postStr:" . $postStr); if (!empty($postStr)) { libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); // $msgType = trim($postObj->MsgType); log_file("msgType:{$msgType}"); switch ($msgType) { case "text": $resultStr = handleText($postObj); break; case "event": $resultStr = handleEvent($postObj); break; case "video": $resultStr = handleVideo($postObj); break; case "voice": $resultStr = handleVoice($postObj); break; case "image": $resultStr = handleImage($postObj); break; default: $resultStr = response_text($postObj, ""); break; } echo $resultStr; } else { echo ""; exit; } }