求一个微信公共平台给公共号发消息成功的代码
在腾讯api上的网页调试成功,但是自己用php代码post过去就不行
回复讨论(解决方案) valid();class wechatcallbackapitest{ public function valid() { $echostr = $_get[echostr]; //valid signature , option if($this->checksignature()){ echo $echostr; exit; } } public function responsemsg() { //get post data, may be due to the different environments $poststr = $globals[http_raw_post_data]; //extract 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 = $keyword; $resultstr = sprintf($texttpl, $fromusername, $tousername, $time, $msgtype, $contentstr); echo $resultstr; }else{ echo input something...; } }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; } }}?>
直接用官方的就可以了啊
有一种开源微信管理平台叫微擎.....