测试案例:
目的:调用外部接口
缺点:腾讯的域名校验麻烦
1.先设置不验证域名是否合法
2.界面.wmxl
<button bindtap='liuyan'> 留言</button>
3.后台.js:获取微信需要的
string access_token
这里只填appid和secret参数就好了,client_credential这个参数不用改就是这个。
扫描二维码关注公众号,回复:
4352062 查看本文章
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解析直接一步一步.(点),如果是数组呢?
}
})
},