公司动态
个人微信API二次开发:在线检测却发失败
运维看检查在线为真告警推送仍失败。有人把toWxid改来改去。其实节点已经半掉线检测接口还返回 200发送通道已经断。发送接口的字段说明也可以对照API 文档在线为真之后必须探测发送GeWe API 提供检查在线。探测只发给自己或文件传输助手不要拿客户当探针。importrequests HEADERS{X-GEWE-TOKEN:YOUR_TOKEN,Content-Type:application/json,}defcheck_online(app_id):returnrequests.post(http://api.geweapi.com/gewe/v2/api/login/checkOnline,headersHEADERS,json{appId:app_id},timeout20,).json()defprobe_send(app_id,self_wxid):returnrequests.post(http://api.geweapi.com/gewe/v2/api/message/postText,headersHEADERS,json{appId:app_id,toWxid:self_wxid,content:在线探测勿回},timeout30,).json()defready(app_id,self_wxid):oncheck_online(app_id)ifon.get(ret)!200:returnFalse,check_failed,on sentprobe_send(app_id,self_wxid)ifsent.get(ret)!200:returnFalse,send_failed_need_relogin,sentreturnTrue,ok,sentready为假时走掉线重连不要循环改客户 wxid。检测字段名以登录模块为准。Token 错误和掉线要分开前者所有接口失败后者可能只有发送失败。平台入口GeWe API 官网收口上线前同时看在线检测和发给自己。两步都过再推业务告警。