Home >php教程 >php手册 >微信后台最基础开发

微信后台最基础开发

WBOY
WBOYOriginal
2016-06-06 19:35:241118browse

自己闲来无事写的 无 ?php//载入消息模板include_once("model.php");//获取数据$postStr=$GLOBALS["HTTP_RAW_POST_DATA"];if (!empty($postStr)) {//解析数据$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername

自己闲来无事写的
<?php
	//载入消息模板
	include_once("model.php");
	//获取数据
	$postStr=$GLOBALS["HTTP_RAW_POST_DATA"];

	if (!empty($postStr)) {
		//解析数据
		$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
          $fromUsername = $postObj->FromUserName;
          $toUsername = $postObj->ToUserName;
          $form_MsgType = $postObj->MsgType;

		if ($form_MsgType=="text") {
			$form_Content = trim($postObj->Content);
        }
			$msgType="text";
			//拼装,sprintf 这个函数很有意思
			$resultStr = sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$form_Content);
			echo $resultStr;
	}
	else{
		$msgType="text";
		$resultStr = sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,'不是文字输入');
		echo $resultStr;
		exit;
	}

?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn