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

微信第三方开放平台全网发布验证

我们的业务是把大量客户的微信公众号 通过授权 给微信第三方开放平台的方式,通过第三方开放平台对客户公众号接口进行代操作。
其中的微信第三方开放平台在测试阶段(未全网发布),能授权的公众号只能是加入到白名单中的。所以托管大量的公众号,必须要对其全网发布。
而全网发布的时候,微信方会进行模拟公众号和粉丝微信号对你的第三方开放平台进行验证:
laravel下面的部分验证代码如下:
1  if($app_id == 'wx570bc396a51b8ff8'){ 2 if($msgtype == 'text'){//普通文本验证 3 $reptype = text; 4 $content = $this->getrecmsg_content(); 5 if($content == 'testcomponent_msg_type_text'){ 6 $repcont = 'testcomponent_msg_type_text_callback'; 7 }else{//api验证 8 $repcont = explode(:,$content)[1];//接受微信放发来的query_auth_code 9 $msgcontent = [content=>$repcont.'_from_api'];10 //获取access_token11 $client = new client(['base_uri' => 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth']);12 $client_result = $client->post('?component_access_token=此时有效的第三方开放平台access_token',['json' => ['component_appid'=>'你的component_appid', 'authorization_code'=>$repcont]])->getbody();13 $access_token = json_decode($client_result,true)['authorization_info']['authorizer_access_token'];14 //发客服消息15 app::make('weixin.cp')->setauthorizertoken($access_token)->sendkefumsg($this->getfromusername(),'text',$msgcontent);16 $repcont = $repcont.'_from_api';17 }18 }elseif($msgtype == 'event'){//事件验证19 $reptype = text;20 $repcont = $msgevent.from_callback;21 }
//返回给微信xml22 $weixin_mp = app::make('weixin.mp');23 $weixin_mp->on($reptype, function() use($reptype,$repcont) {24 return app::make('weixin.mp')->makemessage($reptype ,$repcont);25 });26 $response = $weixin_mp->trigger($reptype);27 return $response;28 }
开始检测,好紧张:
然后结果是:
成功!!!
微信的官方手册:
网布发布验证手册
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419318611&token=&lang=zh_cn
第四步:使用授权码换取公众号的接口调用凭据和授权信息
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1453779503&token=&lang=zh_cn
发客服消息:
http://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html
其它类似信息

推荐信息