<address id="ttjl9"></address>

      <noframes id="ttjl9"><address id="ttjl9"><nobr id="ttjl9"></nobr></address>
      <form id="ttjl9"></form>
        <em id="ttjl9"><span id="ttjl9"></span></em>
        <address id="ttjl9"></address>

          <noframes id="ttjl9"><form id="ttjl9"></form>

          獲取網頁授權

          2018-4-23    seo達人

          如果您想訂閱本博客內容,每天自動發到您的郵箱中, 請點這里

          在微信登錄中,如何和獲取網頁授權。

          一、登錄微信測試公眾品平臺,修改網頁授權基本信息,輸入授權回調頁面域名(自己的域名)。

          然后重新建立一個tp框架 編寫方法如圖:

          [php] view plain copy
          1. <?php  
          2. namespace Home\Controller;  
          3. use Think\Controller;  
          4. class IndexController extends Controller {  
          5.     public function index(){  
          6.        $appid='wx27f664ab15ecb71d';  
          7.        $redirect_uri=urlencode('http://www.crimson1.top/vote/index.php/home/index/getcode');  
          8.        $url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";  
          9.   
          10.              header("Location:".$url);  
          11.     }  
          12.   
          13.     public function getcode(){  
          14.         $code=$_GET["code"];  
          15.          $json=$this->access_token($code);  
          16.          echo $json;  
          17.     }  
          18.     public function access_token($code){  
          19.         $appid="wx27f664ab15ecb71d";  
          20.         $appsecret="015756334f2982ed1189c6d66dbc0353";  
          21.         $url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$appsecret&code=$code&grant_type=authorization_code";  
          22.   
          23.         $ret=https_request($url);  
          24.         return $ret;  
          25.     }  
          26. }  

          在公共模塊中新建function.php

          [php] view plain copy
          1. <?php  
          2. function https_request($url){  
          3.     $curl=curl_init();  
          4.     curl_setopt($curl, CURLOPT_URL, $url);  
          5.     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);  
          6.     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);  
          7.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
          8.     $data=curl_exec($curl);  
          9.     if(curl_errno($curl)){  
          10.         return 'ERROR'.curl_error($curl);  
          11.     }  
          12.     curl_close($curl);  
          13.     return $data;  
          14. }  

          在自己的手機端訪問,就能獲取access_token;

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          日歷

          鏈接

          個人資料

          藍藍設計的小編 http://www.syprn.cn

          存檔

          亚洲va欧美va天堂v国产综合