微信接口开发错误提示 “{“errcode”:40001,”errmsg”:”invalid credential”}”
在做微信接口开发自定义菜单时,代码总是报 ”{“errcode”:40001,”errmsg”:”invalid credential”}”。后来发现token和access_token原来是不同的概念,token是在微信后台选择开发模式的时候填写的,而access_token则是通过接口调用生成的。
调用的语句是:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET结果会返回一个json格式的access_toke值。
注意 json_decode()解析json后的结果是对象,注意不是数组哦,所以access_token 是 $weixindata->access_token 而不是$weixindata['access_token']。