小程序接口调用:Get

测试案例:

目的:调用外部接口

缺点:腾讯的域名校验麻烦

1.先设置不验证域名是否合法

2.界面.wmxl

<button bindtap='liuyan'> 留言</button>

3.后台.js:获取微信需要的

string access_token

接口调用凭证

这里只填appid和secret参数就好了,client_credential这个参数不用改就是这个。

liuyan:function(e)

{

wx.request({

url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=xxxxxxxx&secret=xxxxxxxxxx',

success: function (res) {

console.log(res.data.access_token) //打印返回值的access_token,这里不用Json解析直接一步一步.(点),如果是数组呢?

}

})

},

猜你喜欢

转载自blog.csdn.net/weixin_42401291/article/details/83863878