易信公众平台接口文件代码,只要将文件里的token换成自己定义的就可以直接放到自己的空间上了。注意:token值要跟您在开发模式那里写的一样。
/**
* wechatphp test
*/
//define your token
define("TOKEN", "自己设定的值");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
classwechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
//valid signature , option
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
public function responseMsg()//接受用户信息并返回图文信息
{
$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);
$time = time();
$textTpl = "
%s
1