第一个公众微信demo老是运行不成功
我找了很多代码了,差不多都是如下代码:
valid();
$wechatobj->responsemsg();
class wechatcallbackapitest
{
public function valid()
{
$echostr = $_get[echostr];
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
0
;
if(!empty( $keyword ))
{
$msgtype = text;
$contentstr = '你好啊,屌丝';
$resultstr = sprintf($texttpl, $fromusername, $tousername, $time, $msgtype, $contentstr);
echo $resultstr;
}else{
echo '咋不说哈呢';
}
}else {
echo '咋不说哈呢';
exit;
}
}
private function checksignature()
{
$signature = $_get[signature];
$timestamp = $_get[timestamp];
$nonce = $_get[nonce];
$token =token;
$tmparr = array($token, $timestamp, $nonce);
sort($tmparr);
$tmpstr = implode( $tmparr );
$tmpstr = sha1( $tmpstr );
if( $tmpstr == $signature ){
return true;
}else{
return false;
}
}
}
?>
运行时老是提示【该公众号暂时无法提供服务】,请大神看下哪里出了问题?
------解决思路----------------------
哥们,帮我看看这个问题吧http://bbs.csdn.net/topics/390946850
------解决思路----------------------
去我的博客看看吧
------解决思路----------------------
微信回复都是要已xml格式返回,怎么判断条件中还有直接echo的。