公众号生成带参数二维码,采用{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "test"}}}格式,步骤如下:
1、POST https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0},获取到{"ticket":"gQGi8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUU82bG8wdkhmREQxeGkzczFBMUwAAgTSyJJkAwSAOgkA","expire_seconds":604800,"url":"http://weixin.qq.com/q/02QO6lo0vHfDD1xi3s1A1L"}
2、通过ticket换取二维码 GET https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGi8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUU82bG8wdkhmREQxeGkzczFBMUwAAgTSyJJkAwSAOgkA
以上两个步骤都成功,扫描scene_str值不一样的二维码图片,后台接收到的信息一样,且没有看到参数scene_str,如下:
<xml><ToUserName><![CDATA[gh_34cc79c09e6c]]></ToUserName>
<FromUserName><![CDATA[on2vn59fH3FvhZZPNG_YvUzJEENk]]></FromUserName>
<CreateTime>1687340674</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[SCAN]]></Event>
<EventKey><![CDATA[0]]></EventKey>
<Ticket><![CDATA[gQGD8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyckJOdm9FdkhmREQxSkM3aWhBMXMAAgQ6xpJkAwQsAQAA]]></Ticket>
</xml>
请指导下,问题出在哪里?另外第一个步骤里获取到的url,开发者可根据该地址自行生成需要的二维码图片,指导下如何自行生成,谢谢。
EventKey的值一直为0?我传入的如hello或test,但EventKey都是0
2: 检查json格式是否正确