您好,欢迎访问一九零五行业门户网

有没开发过微信公众号的?

请教一个问题:假设我现在已经申请号了认证订阅号,然后我也启用了服务器配置并且url验证通过了。但是我尝试用自己的微信关注这个订阅号,并且发送消息。理论上微信服务器应该会向url发送用户的信息,包括openid什么的。但是实际上我的url里面并没有接收到任何信息。不知道是否有开发过的大侠指点一下?
我的url内的代码:
tracehttp();define(token, 4321);$access_token = '1234';$wechatobj = new wechatcallbackapitest();if (isset($_get['echostr'])) { $wechatobj->valid();}else{ $wechatobj->responsemsg();}class wechatcallbackapitest{ public function valid() { $echostr = $_get[echostr]; if($this->checksignature()){ echo $echostr; 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; } } public function responsemsg() { $poststr = $globals[http_raw_post_data]; ob_start(); var_dump($_request); $a = ob_get_clean(); file_put_contents('1.xml', $a, file_append); 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($keyword == ? || $keyword == ?) { $msgtype = text; $contentstr = date(y-m-d h:i:s,time()); $resultstr = sprintf($texttpl, $fromusername, $tousername, $time, $msgtype, $contentstr);// echo $resultstr; file_put_contents('1.xml', $resultstr, file_append); } }else{ echo ; exit; } }}function tracehttp(){ logger(\n\nremote_addr:.$_server[remote_addr].(strstr($_server[remote_addr],'101.226')? from weixin: unknown ip)); logger(query_string:.$_server[query_string]);}function logger($log_content){ if(isset($_server['http_appname'])){ //sae sae_set_display_errors(false); sae_debug($log_content); sae_set_display_errors(true); }else{ //local $max_size = 500000; $log_filename = log.xml; if(file_exists($log_filename) and (abs(filesize($log_filename)) > $max_size)){unlink($log_filename);} file_put_contents($log_filename, date('y-m-d h:i:s').' '.$log_content.\r\n, file_append); }}
每次我向订阅号发消息后,1.xml确实会有新内容被记录,但只有这些:
array(3) { [signature]=> string(40) 2c1f15c808659e38ca8a2bef53068939c7710d09 [timestamp]=> string(10) 1423321593 [nonce]=> string(10) 1992378621}
百思不得其解。
回复讨论(解决方案) http://blog.csdn.net/fuyifang/article/details/40707517
这篇文章我已经看过了,按照文章所说,当我向订阅号发送消息的时候,微信服务器会向订阅号填写的服务器url发送xml格式数据,里面就有用户的openid。问题就是我服务器url这边是接收到微信服务器的发送数据,可是数据里面没有xml格式的数据啊,也没有openid。
腾    讯 微信开发 有技术咨询吧?         程序规则他们定制的  最好问下他们
检查下你服务器配置的消息加解密方式,看是否是明文的
你的代码是什么样程序就会表现什么样
注释掉下面几句:
ob_start();
var_dump($_request);
 $a = ob_get_clean();
 file_put_contents('1.xml', $a, file_append);
然后向你的公众号发送问号(?)试试
问题已经解决了,就是5楼说的问题。不能用
ob_start();
var_dump($_request);
 $a = ob_get_clean();
其它类似信息

推荐信息