rest - Token error when sending Wechat message with Python -


i have wechat subscribe page, , set in https://admin.wechat.com/ token webhook url of server myserver.com/wechat/webhook

my server python code authenticates wechat server signature check, nonce , timestamp , i'm able receive messages wechat webhook.

but can't send messages server wechat, i'm using following code , token set in admin console previously, , following previous docs: http://admin.wechat.com/wiki/index.php?title=customer_service_messages

# parse received wechat message message = xmltodict.parse(message)  content = message['xml']['content'] fromuser = message['xml']['fromusername'] touser = message['xml']['tousername'] createdtime = message['xml']['createtime']  # reply message post_data = {    "touser": fromuser,    "msgtype": "text",    "text":    {         "content": "thanks message"    } } api_url = 'https://api.wechat.com/cgi-bin/message/custom/send?access_token=' + token response = requests.post(api_url, data=post_data) content = response.content 

this error i'm getting:

{"errcode":40001,"errmsg":"invalid credential, access_token invalid or not latest hint: [udq9ka0880vr32!]"} 

what token supposed use? or error? thanks

i think might permission problem... in wechat page admin console, says have permission obtained auto-reply, not service api. can confirm this?

indeed tested instantly replying post messages http response (auto-reply or callback) http://admin.wechat.com/wiki/index.php?title=callback_messages

and service api seems not working (which purpose of question) http://admin.wechat.com/wiki/index.php?title=customer_service_messages


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -