国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Maison php教程 php手冊 微信第三方開放平臺全網發(fā)布驗證

微信第三方開放平臺全網發(fā)布驗證

Sep 24, 2016 am 09:02 AM

我們的業(yè)務是把大量客戶的微信公眾號 通過授權 給微信第三方開放平臺的方式,通過第三方開放平臺對客戶公眾號接口進行代操作。

其中的微信第三方開放平臺在測試階段(未全網發(fā)布),能授權的公眾號只能是加入到白名單中的。所以托管大量的公眾號,必須要對其全網發(fā)布。

?

而全網發(fā)布的時候,微信方會進行模擬公眾號和粉絲微信號對你的第三方開放平臺進行驗證:

laravel下面的部分驗證代碼如下:

<span style="color: #008080;"> 1     </span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$app_id</span> == 'wx570bc396a51b8ff8'<span style="color: #000000;">){
</span><span style="color: #008080;"> 2</span>             <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$MsgType</span> == 'text'){<span style="color: #008000;">//</span><span style="color: #008000;">普通文本驗證</span>
<span style="color: #008080;"> 3</span>                 <span style="color: #800080;">$repType</span> = "text"<span style="color: #000000;">;
</span><span style="color: #008080;"> 4</span>                 <span style="color: #800080;">$content</span> = <span style="color: #800080;">$this</span>-><span style="color: #000000;">getRecMsg_Content();
</span><span style="color: #008080;"> 5</span>                 <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$content</span> == 'TESTCOMPONENT_MSG_TYPE_TEXT'<span style="color: #000000;">){
</span><span style="color: #008080;"> 6</span>                     <span style="color: #800080;">$repCont</span> = 'TESTCOMPONENT_MSG_TYPE_TEXT_callback'<span style="color: #000000;">;
</span><span style="color: #008080;"> 7</span>                 }<span style="color: #0000ff;">else</span>{<span style="color: #008000;">//</span><span style="color: #008000;">API驗證</span>
<span style="color: #008080;"> 8</span>                     <span style="color: #800080;">$repCont</span> =  <span style="color: #008080;">explode</span>(":",<span style="color: #800080;">$content</span>)[1];<span style="color: #008000;">//</span><span style="color: #008000;">接受微信放發(fā)來的query_auth_code</span>
<span style="color: #008080;"> 9</span>                     <span style="color: #800080;">$msgcontent</span> = ["content"=><span style="color: #800080;">$repCont</span>.'_from_api'<span style="color: #000000;">];
</span><span style="color: #008080;">10</span>                      <span style="color: #008000;">//</span><span style="color: #008000;">獲取access_token</span>
<span style="color: #008080;">11</span>                     <span style="color: #800080;">$Client</span> = <span style="color: #0000ff;">new</span> Client(['base_uri' => 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth'<span style="color: #000000;">]);
</span><span style="color: #008080;">12</span>                     <span style="color: #800080;">$client_result</span> = <span style="color: #800080;">$Client</span>->post('?component_access_token=此時有效的第三方開放平臺access_token',['json' => ['component_appid'=>'你的component_appid', 'authorization_code'=><span style="color: #800080;">$repCont</span>]])-><span style="color: #000000;">getBody();
</span><span style="color: #008080;">13</span>                     <span style="color: #800080;">$access_token</span> = json_decode(<span style="color: #800080;">$client_result</span>,<span style="color: #0000ff;">true</span>)['authorization_info']['authorizer_access_token'<span style="color: #000000;">];
</span><span style="color: #008080;">14</span>                     <span style="color: #008000;">//</span><span style="color: #008000;">發(fā)客服消息</span>
<span style="color: #008080;">15</span>                     App::make('weixin.cp')->setAuthorizerToken(<span style="color: #800080;">$access_token</span>)->sendKeFuMsg(<span style="color: #800080;">$this</span>->getFromUserName(),'text',<span style="color: #800080;">$msgcontent</span><span style="color: #000000;">);
</span><span style="color: #008080;">16</span>                     <span style="color: #800080;">$repCont</span> = <span style="color: #800080;">$repCont</span>.'_from_api'<span style="color: #000000;">;
</span><span style="color: #008080;">17</span> <span style="color: #000000;">                }
</span><span style="color: #008080;">18</span>             }<span style="color: #0000ff;">elseif</span>(<span style="color: #800080;">$MsgType</span> == 'event'){<span style="color: #008000;">//事件</span><span style="color: #008000;">驗證</span>
<span style="color: #008080;">19</span>                 <span style="color: #800080;">$repType</span> = "text"<span style="color: #000000;">;
</span><span style="color: #008080;">20</span>                 <span style="color: #800080;">$repCont</span> = <span style="color: #800080;">$MsgEvent</span>."from_callback"<span style="color: #000000;">;
</span><span style="color: #008080;">21</span> <span style="color: #000000;">            }<br><br>         //返回給微信xml
</span><span style="color: #008080;">22</span>             <span style="color: #800080;">$weixin_mp</span> = App::make('weixin.mp'<span style="color: #000000;">);
</span><span style="color: #008080;">23</span>             <span style="color: #800080;">$weixin_mp</span>->on(<span style="color: #800080;">$repType</span>, <span style="color: #0000ff;">function</span>() <span style="color: #0000ff;">use</span>(<span style="color: #800080;">$repType</span>,<span style="color: #800080;">$repCont</span><span style="color: #000000;">) {
</span><span style="color: #008080;">24</span>                 <span style="color: #0000ff;">return</span> App::make('weixin.mp')->makeMessage(<span style="color: #800080;">$repType</span> ,<span style="color: #800080;">$repCont</span><span style="color: #000000;">);
</span><span style="color: #008080;">25</span> <span style="color: #000000;">            });
</span><span style="color: #008080;">26</span>             <span style="color: #800080;">$response</span> = <span style="color: #800080;">$weixin_mp</span>->trigger(<span style="color: #800080;">$repType</span><span style="color: #000000;">);
</span><span style="color: #008080;">27</span>             <span style="color: #0000ff;">return</span> <span style="color: #800080;">$response</span><span style="color: #000000;">;
</span><span style="color: #008080;">28</span>         }

?

開始檢測,好緊張:

?

然后結果是:

成功!?。?/p>

?

?

?

?

微信的官方手冊:

網布發(fā)布驗證手冊

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

發(fā)客服消息:

http://mp.weixin.qq.com/wiki/11/c88c270ae8935291626538f9c64bd123.html

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefa?on, veuillez contacter admin@php.cn

Outils d'IA chauds

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

Video Face Swap

Video Face Swap

échangez les visages dans n'importe quelle vidéo sans effort grace à notre outil d'échange de visage AI entièrement gratuit?!

Outils chauds

Bloc-notes++7.3.1

Bloc-notes++7.3.1

éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise

SublimeText3 version chinoise

Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1

Envoyer Studio 13.0.1

Puissant environnement de développement intégré PHP

Dreamweaver CS6

Dreamweaver CS6

Outils de développement Web visuel

SublimeText3 version Mac

SublimeText3 version Mac

Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Tutoriel PHP
1502
276