问题
在计划任务执行过程中报错,报返回信息内没有unionId,经过实测,是因为当前用户取关了公众号,所以获取不到用户unionId
问题原因:
用户未关注公众号或未授权给该公众号获取其 unionid。在用户未关注公众号时,无法通过公众号接口获取其 unionid。
取消关注/未关注公众号用户返回数据
object(stdClass)#17 (10) { ["subscribe"]=> int(0) ["openid"]=> string(28) "ohf9awblp6M898m21w-sSIck" ["nickname"]=> string(0) "" ["sex"]=> int(0) ["language"]=> string(5) "zh_CN" ["city"]=> string(0) "" ["province"]=> string(0) "" ["country"]=> string(0) "" ["headimgurl"]=> string(0) "" ["tagid_list"]=> array(0) { } }
已关注用户返回数据:
object(stdClass)#18 (17) { ["subscribe"]=> int(1) ["openid"]=> string(28) "ohf9awed88883Twy7CuJ1E6Y4" ["nickname"]=> string(0) "" ["sex"]=> int(0) ["language"]=> string(5) "zh_CN" ["city"]=> string(0) "" ["province"]=> string(0) "" ["country"]=> string(0) "" ["headimgurl"]=> string(0) "" ["subscribe_time"]=> int(1705999124) ["unionid"]=> string(28) "oSpO==e_4Xm_cIXy4Cu6MoD0" ["remark"]=> string(0) "" ["groupid"]=> int(0) ["tagid_list"]=> array(0) { } ["subscribe_scene"]=> string(17) "ADD_SCENE_QR_CODE" ["qr_scene"]=> int(0) ["qr_scene_str"]=> string(25) "1705999105" }
相关问题
1.微信获取用户信息接口/cgi-bin/user/info的坑,不同用户返回信息不一致