收藏
回答

消息推送配置-Token校验返回200302

{"base_resp":{"err_msg":"verify token fail","ret":200302}}


我把微信调用的请求信息打印出来,手动发送命令,返回的就是echostr的值,是字符串的

回答关注问题邀请回答
收藏

7 个回答

  • 小季同学4pro
    小季同学4pro
    2019-11-15

    python连接,同问

    我甚至跳过验证,都提示失败??????

    import web
    import hashlib
     
    urls = (
        '/wx', 'Handle',
    )
     
    class Handle(object):
        def GET(self):
            try:
                data = web.input()
                if len(data) == 0:
                    return "hello, this is handle view"
                return data.echostr
            except Exception as Argument:
                return Argument
                 
    if __name__ == '__main__':
        app = web.application(urls, globals())
        app.run()

    {"base_resp":{"ret":200302,"err_msg":"verify token fail"}}

    请问官方到底是什么情况啊?你们文档是我看到现在写的最模糊的,各种问题

    2019-11-15
    有用 1
    回复
  • Monk
    Monk
    2019-08-09

    我python3.5

    # -*- coding: utf-8 -*-
    # filename: handle.py
     
    import hashlib
    import web
     
    class Handle(object):
        def GET(self):
            try:
                data = web.input()
                if len(data) == 0:
                    return "hello, this is handle view"
                signature = data.signature
                timestamp = data.timestamp
                nonce = data.nonce
                echostr = data.echostr
     
                token = "123" #请按照公众平台官网\基本配置中信息填写
                list = [token, timestamp, nonce]
                list.sort()
     
                list = [token, timestamp, nonce]
                list.sort()
                # python2.7
                # sha1 = hashlib.sha1()
                # map(sha1.update, list)
                # hashcode = sha1.hexdigest()
     
                # python3.x
                sha1 = hashlib.sha1()
                sha1.update(list[0].encode("utf-8"))
                sha1.update(list[1].encode("utf-8"))
                sha1.update(list[2].encode("utf-8"))
                hashcode = sha1.hexdigest()  # 获取加密串
     
                # python3.x
                # temp = ''.join(list)
                # sha1 = hashlib.sha1(temp.encode('utf-8'))
                # map(sha1.update, list)
                # hashcode = sha1.hexdigest()
                # print("handle/GET func: hashcode, signature: ", hashcode, signature)
                if hashcode == signature:
                    # print(echostr)
                    return echostr
                else:
                    return ''
            except Exception:
                return Exception

    后台看见200 ok,echostr也return了,依旧token验证失败

    2019-08-09
    有用 1
    回复
  • 穹隆天天
    穹隆天天
    2019-03-13

    经测试,文档中  “ 开发者通过检验signature对请求进行校验(下面有校验方式)。若确认此次GET请求来自微信服务器,请原样返回echostr参数内容,则接入生效,成为开发者成功,否则接入失败。”  (https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319) ,所谓“原样返回echostr参数内容”,就是说直接把echostr写到应答包体中即可,不带任何格式即可成功,文档原文表述不清晰。成功的校验抓包如下:


    GET /shwx/api/callback?signature=67e14d2ed1f32698bab9ed7b673fab3f8ab7f902&echostr=382485513798135407&timestamp=1552460909&nonce=583572733 HTTP/1.0

    Host: gzh

    Connection: close

    User-Agent: Mozilla/4.0

    Accept: */*

    Pragma: no-cache


    HTTP/1.1 200 OK

    Date: Wed, 13 Mar 2019 07:08:29 GMT

    X-Application-Context: application:8083

    Content-Type: text/plain;charset=iso-8859-1

    Content-Length: 18


    382485513798135407




    2019-03-13
    有用 1
    回复 3
    • 闫鹏强
      闫鹏强
      2020-03-01
      我修改 Content-Type 和 charset 后验证成功了,之前设置的是 application/json。
      2020-03-01
      回复
    • 闫鹏强
      闫鹏强
      2020-03-01
      谢谢🙏
      2020-03-01
      回复
    • 邱微凡
      邱微凡
      2023-11-27
      感谢好人帮我渡劫
      2023-11-27
      回复
  • Kidby
    Kidby
    2021-03-27

    c语言的痛,看到抓包才能懂

    2021-03-27
    有用
    回复
  • Bearny
    Bearny
    2019-01-18

    同问

    2019-01-18
    有用
    回复
  • 坤
    2018-09-25

    文档巨坑,说好原样返回的,我就按照返回字符串了,后面转成整型就校验成功了

    2018-09-25
    有用
    回复 2
    • 小季同学4pro
      小季同学4pro
      2019-11-15
      不行啊,我int后还是验证失败
      2019-11-15
      回复
    • 涂修建
      涂修建
      2020-06-25
      转成int之后真的成功了卧槽。文档太太太坑了
      2020-06-25
      回复
  • 是小白啊
    是小白啊
    2018-09-25

    你好,请确认下token正确以及有效是否正确

    2018-09-25
    有用
    回复
登录 后发表内容