小程序
小游戏
企业微信
微信支付
扫描小程序码分享
{"base_resp":{"err_msg":"verify token fail","ret":200302}}
我把微信调用的请求信息打印出来,手动发送命令,返回的就是echostr的值,是字符串的
7 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
python连接,同问
我甚至跳过验证,都提示失败??????
import
web
hashlib
urls
=
(
'/wx'
,
'Handle'
)
class
Handle(
object
):
def
GET(
self
try
:
data
web.
input
()
if
len
(data)
0
return
"hello, this is handle view"
data.echostr
except
Exception as Argument:
Argument
__name__
'__main__'
app
web.application(urls,
globals
())
app.run()
{"base_resp":{"ret":200302,"err_msg":"verify token fail"}}
请问官方到底是什么情况啊?你们文档是我看到现在写的最模糊的,各种问题
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
我python3.5
# -*- coding: utf-8 -*-
# filename: handle.py
signature
data.signature
timestamp
data.timestamp
nonce
data.nonce
echostr
token
"123"
#请按照公众平台官网\基本配置中信息填写
list
[token, timestamp, nonce]
.sort()
# python2.7
# sha1 = hashlib.sha1()
# map(sha1.update, list)
# hashcode = sha1.hexdigest()
# python3.x
sha1
hashlib.sha1()
sha1.update(
[
].encode(
"utf-8"
))
1
2
hashcode
sha1.hexdigest()
# 获取加密串
# temp = ''.join(list)
# sha1 = hashlib.sha1(temp.encode('utf-8'))
# print("handle/GET func: hashcode, signature: ", hashcode, signature)
signature:
# print(echostr)
else
''
Exception:
Exception
后台看见200 ok,echostr也return了,依旧token验证失败
经测试,文档中 “ 开发者通过检验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×tamp=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
c语言的痛,看到抓包才能懂
同问
文档巨坑,说好原样返回的,我就按照返回字符串了,后面转成整型就校验成功了
你好,请确认下token正确以及有效是否正确
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
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"}}
请问官方到底是什么情况啊?你们文档是我看到现在写的最模糊的,各种问题
我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验证失败
经测试,文档中 “ 开发者通过检验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×tamp=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
c语言的痛,看到抓包才能懂
同问
文档巨坑,说好原样返回的,我就按照返回字符串了,后面转成整型就校验成功了
你好,请确认下token正确以及有效是否正确