天天看点

微信小程序怎么获取access_token

先直接说重点:

接口链接:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=AppId&secret=AppSecret

一共三个参数.

参数1:grant_type :grant_type=client_credential,这是固定的不会变

参数2:appid:第三方用户唯一凭证(AppId账号)

参数3:secret:第三方用户唯一凭证秘钥(也就是刚刚得到的AppSecret密钥)

只要参数正确,那么访问该链接就可以获取 access_token。

php端代码

//    获取token
    public function getToken(){
        $appid = 'wx000000000';
        $appsecret = 'd00000000000000000000000000002';
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
        $data = $this->curl_get($
           

继续阅读