参考文档:https://developers.weixin.qq.com/minigame/dev/guide/open-ability/union-id.html
如果开发者拥有多个移动应用、网站应用、和公众帐号(包括小程序),可通过 UnionID 来区分用户的唯一性,因为只要是同一个微信开放平台帐号下的移动应用、网站应用和公众帐号(包括小程序),用户的 UnionID 是唯一的。换句话说,同一用户,对同一个微信开放平台下的不同应用,UnionID是相同的。
{ "unionid":"oQ19D6OLhLKzJTOFJyx5nj2Yd-_g", "openid":"oKeNO44zXYi_sp9WqKZaHQwWvdmU", "session_key":"dFTHtJhhZcNvHvsvR1KnYg==" }
可以使用如下接口进行接收
/** * 公众号回调接口 */ @RequestMapping(value = "/gzh/callback", method = RequestMethod.POST, produces = "application/xml; charset=UTF-8") public String callback(@RequestBody String requestBody, @RequestParam("signature") String signature, @RequestParam("timestamp") String timestamp, @RequestParam("nonce") String nonce, @RequestParam("openid") String openid, @RequestParam(name = "encrypt_type", required = false) String encType, @RequestParam(name = "msg_signature", required = false) String msgSignatur
参考文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html#UinonId
返回值如下:
{ "subscribe": 1, "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", "language": "zh_CN", "subscribe_time": 1382694957, "unionid": " o6_bmasdasdsad6_2sgVt7hMZOPfL", "remark": "", "groupid": 0, "tagid_list":[128,2], "subscribe_scene": "ADD_SCENE_QR_CODE", "qr_scene": 98765, "qr_scene_str": "" }