php新手求微信PHP的注释
/**
* 微信 php 测试
*/
//定义你的token
define("TOKEN", "weixin");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
//有效签名 , 选项
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
public function responseMsg()
{
//获取post数据,可能由于环境不同
$postStr = $GLOBALS["HTTP_RAW_POST_DATA "];
//提取发布数据
if (!empty($postStr)){
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_ NOCDATA);
$fromUsername = $postObj->FromUserName;
$toUsername = $postObj->ToUserName;
$keyword = trim($postObj->Content) ;
$时间 = 时间();
$textTpl = "
内容>
if(!empty( $keyword ))
{
$msgType = "text";
$contentStr = “欢迎来到微信世界!”;
$resultStr = sprintf($textTpl , $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultStr;
}else{
echo “输入一些内容...”;
}
}否则{
echo "";