微信第三方平台的坑

1.如果修改了接受回调ticket的地址,看来是不会实时更新的,收不到ticket又急的话,只能重新申请一个第三方平台。

2.公众号管理员授权(不是用户登录授权)可以做成一个页面,进入页面后实时获取ticket,再跳转授权网址。

3.管理员授权登录时候的解密,String result = pc.decryptMsg(msgSignature, timestamp, nonce, fromXML);其中的fromXML

String xmlFormat = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%1$s]]></Encrypt></xml>";

String fromXML = String.format(xmlFormat, encrypt);

xmlFormat是写死的,encrypt来自request.getInputStream()的xml解析,解析部分官网demo有

4.用户授权登录,就是当从公众号进入第三方平台地址的收,不要用本来的地址,而是用https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE&component_appid=component_appid#wechat_redirect

具体是在文档“代公众号发起网页授权”这里。

5.用户授权后,code换token,官方文档有错误,正确应该是

https://api.weixin.qq.com/sns/oauth2/access_token?appid=appid&secret=secret&code=code&grant_type=authorization_code

6.网页调用js方法,需要

扫描二维码关注公众号,回复: 10369818 查看本文章

a.利用10分钟一次的ticket换取component_access_token

b.管理员授权后的auth_code

api_query_auth接口换取access_token,注意和component_access_token不一样,最后再用access_token换取ticket

发布了15 篇原创文章 · 获赞 3 · 访问量 6538

猜你喜欢

转载自blog.csdn.net/yushiershi/article/details/82462750