[{"attributes":{"bold":true},"insert":"实现效果"},{"attributes":{"header":3},"insert":"\n"},{"insert":{"image":"R10512487-ae65d9cf8f615965ade82334da0fa03d_132555_304_456.png"}},{"insert":"\n\n"},{"attributes":{"lineHeight":"100%","bold":true},"insert":"1.公众号和后台api配置"},{"attributes":{"header":3},"insert":"\n"},{"insert":"\n"},{"attributes":{"color":"#333333","lineHeight":"100%"},"insert":"【设置与开发】>【配置】> 【服务器配置】"},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":" "},{"insert":"\n"},{"attributes":{"color":"#333333","lineHeight":"100%"},"insert":"url为后台公开api的地址,Token的值可以随便设置,在后续发送消息时会用到,AESKey用于消息的解密,测试的时候你可以选择明文模式先看一下,实际运营中需要使用加密模式"},{"insert":"\n"},{"insert":{"image":"R10512487-ed005c61f8e3066be0de538ea3a9ca1f_261095_1036_857.png"}},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"打开配置后,你需要在你的后台设置一个公开的api,外网可以访问的那种,配置阶段,服务只需要做一个事情就是返回值里面的echostr,这样才能成功的配置提交,否则它将报错token错误;"},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"原理:提交的动作微信会给你的api发起一个get请求,你需要返回一个echostr来回应,才能调通;这是最基础的,因为测试是用的明文,所以没对安全性进行校验,下面是校验的方法"},{"insert":"\n"},{"insert":{"image":"R10512487-7ea1314a526df1e51851f8a4bc730704_81460_690_377.png"}},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"后台api设置如下:test这个路径值可以随便设置,这里在公众号配置的时候需要把返回格式那儿设置为JSON,不然公众号配置后无法启用,在启用成功后,后台api返回格式设置为XML格式,能正确的启用api,就算成功了"},{"insert":"\n\n"},{"insert":{"image":"R10512487-dd9e1b4bb1bca156bf3304f4a6f01c66_329617_1261_645.png"}},{"insert":"\n"},{"attributes":{"header":2},"insert":"\n"},{"attributes":{"lineHeight":"100%","bold":true},"insert":"2.接收消息配置"},{"attributes":{"header":3},"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"接收消息大概分为用户主动发送/点击自定义菜单栏,事件event类型主要是关注/取消关注/进入公众号三种类型,消息可以分为文字/图片/语音等等,这里着重描述关注/进入/文字消息类型的处理,其余的自行微信公众平台上找到文档修改参数"},{"insert":"\n"},{"insert":{"image":"R10512487-0cf43cdc48ae3145937deb3ac0d074d0_256073_1207_602.png"}},{"insert":"\n"},{"attributes":{"header":4},"insert":"\n"},{"attributes":{"lineHeight":"100%","bold":true},"insert":"1)消息内容解密"},{"attributes":{"header":4},"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"调试可以用明文模式,在上面公众号配置里面有选项,但是不宜实际使用,直接用密文格式;"},{"insert":"\n\n"},{"insert":{"image":"R10512487-e87a786318650ee4c4df6467f2e7b182_101216_596_464.png"}},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"后台参数第一个AESKey在公众号配置中复制过来,appid公众号的配置,可以自行找到后填入,此两个参数必填"},{"insert":"\n"},{"insert":{"image":"R10512487-03c3b72783a172af97c68676d40656de_148535_868_259.png"}},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"解密后的参数一般是这样的,Event代表消息触发的类型,这里是扫码浏览访问了公众号,EventKey值如果扫码值里面有就会显示,ToUserName是公众号的id,FromUserName是访问者的openid(openid是不固定的,同一个人每个公众号内的openid各不相同)"},{"insert":"\n\n"},{"attributes":{"lineHeight":"100%","bold":true},"insert":"2)扫码关注情况下的配置"},{"attributes":{"header":4},"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"扫码关注需要获取制定的扫码二维码url,里面可以携带参数,服务如下:"},{"insert":"\n"},{"insert":{"image":"R10512487-1d79b101906f0570ff02aa02f2dd372c_794987_1860_670.png"}},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"这里用到后台微信的缓存凭证功能,因为微信对重复获取凭证一天的限制是2000次,所以在有效期内需要重复利用,需要配置后台微信,appid和appsecret是必须的,请提前准备"},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"场景值可以根据需要传入不同的id值来用于接收后判断操作,我这里就填了个123"},{"insert":"\n"},{"insert":{"image":"R10512487-78bd389bd92f89d54ee840e4401709ef_63888_440_372.png"}},{"insert":"\n"},{"attributes":{"lineHeight":"100%","color":"#494949"},"insert":"前台用一个按钮调用服务后把url给二维码图片即可,如果是失败则显示失败原因"},{"insert":"\n\n"},{"attributes":{"bold":true},"insert":"3)接收关注信息"},{"attributes":{"header":4},"insert":"\n"},{"insert":"后台会根据event类型来判断关注和已关注后的情况,分别对应subscribe和SCAN,可以在这两种情况下去发送不同的消息和处理登录等事件,我这里演示就只是发送两个消息\n"},{"insert":{"image":"R10512487-ff3a88f8f377cd25f2728162b730a391_524972_1634_654.png"}},{"insert":"\n这儿的接收参数这个蓝色的值,等于直接在接收参数那里填写一个值,如下,如果你这样写了,那就直接用xml这个参数就行了,不用再像我那样写,微信服务器会传值的\n"},{"insert":{"image":"R10512487-87ef8428a32d7688c4998f017f5e0c86_80750_1203_260.png"}},{"insert":"\n"},{"attributes":{"header":4},"insert":"\n"},{"attributes":{"size":"14px","bold":true},"insert":"4)文本回复"},{"attributes":{"header":4},"insert":"\n"},{"insert":"文本对应text事件类型,消息类都算text,里面可以细分,可以自己发送消息,然后打开服务的日志查看返回的值来一一对应处理就可以了,很多类型,就不写完了;\n常规方式就是对内容进行判断,包含等于这些操作,然后根据情况回复对应的内容\n"},{"insert":{"image":"R10512487-5207dac47135597424a3e8898f7e9495_271699_1075_639.png"}},{"insert":"\n"}]
[{"insert":"在iVX后台通过接口设置公众自动回复的消息内容和规则\n"}]
微信公众号配置扫码关注功能,通过生成微信指定规则的二维码,用户扫描后微信服务器发送消息到我们的后台,接收后根据需要回复消息提示等各种操作
R10580997-748517bd9303e02386d5029e83b441c5_29861_502_405.png
https://file5fcd0516f8b6.v4.h5sys.cn/play/nSCa7gYz