小程序登录的时候,如何在后端判断小程序是否关注公众号?

小程序 文章 2021-03-05 19:01 563 0 全屏看文

AI助手支持GPT4.0

小程序登录的时候,如何在后端判断小程序是否关注公众号?When the Mini Program is logged in, how can I judge whether the Mini Program pays attention to the official account on the backend?

小程序登录的时候,如何在后端判断小程序是否关注公众号?

1,现在unionid可以随便获取了,所以无法根据jscode2session判断用户是否关注公众号

2,公众号的api,需要从网页授权获取openid,再通过openid换取用户是否关注公众号的字段,但是,我是要在小程序登录的时候判断用户是否关注公众号,而不是要用到网页。

请问,还有其余方法吗?

1, official account official account official account number 2 is now available for unionid. So, it is impossible to judge whether the user is concerned about the official account number 2 according to jscode2session. The API of the public number needs to be authorized from the webpage to get the openid, and then the user can pay attention to the field of the public number through the openid. However, I want to judge whether the user is concerned with the public number while the small program is logged in, rather than using the web page. Excuse me, is there any other way?

回答:

peng:

不是随便获取,还是要绑定开放平台的

常规思路:

1.公众号与小程序帮同开放平台

2.API公众号的可以拉取关注用户,获取公众号的unionid,保存到自己数据库表

https://developers.weixin.qq.com/doc/offiaccount/User_Management/Getting_a_User_List.html

https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html#UinonId

2.1.最好做公众号的消息推送,用户取消了能获取到取消关注,并更新回数据库

https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html

3.小程序登录用unionid去这个关注用户表查有没有记录,是否没有取消。

老张:

谢邀。

没有办法。

shmily:

这要看你公众号储存用户数据的唯一标识是什么了,如果是手机号的话那就登录的时候获取用户手机号判断数据库是否储存过,但是这个方法有弊端,因为微信手机号不一定是当初储存的手机号。所以我个人还是建议登录的时候请求接口,通过openId和session_key判断数据库是否有这个用户。

searchFan1:我主要是在注册,登录的时候做
Mr.Zhao:

只能去自己数据库查

searchFan1:我主要是在注册,登录的时候做
Mr.Zhao:跟你主要次要没关系

-EOF-

AI助手支持GPT4.0