httplib2模拟登陆微信公共平台出错
模拟登陆微信公共平台
https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN
import httplib2
import hashlib
import urllib
NAME = "**"
PASSWORD = "**"
LOGIN_URL = "http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN"
def login():
"微信登陆接口"
http = httplib2.Http()
md5pwd=hashlib.md5(PASSWORD).hexdigest()
headers = {
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Content-Length": "22",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Pragma": "no-cache",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0",
"X-Requested-With": "XMLHttpRequest",
}
post = {
"username": NAME,
"pwd": md5pwd,
"imgcode": "",
"f": "json"
}
body=urllib.urlencode(post)
request, content = http.request(uri=LOGIN_URL,method= "POST",headers= headers,body= body)
print content
def main():
login()
if __name__ == '__main__':
main()
但是返回的状态编码是-2,就是用户名密码错误,不知道哪里出错了 状态码:
case "-1":
i = "系统错误,请稍候再试。";
break;
case "-2":
i = "帐号或密码错误。";
break;
case "-3":
i = "您输入的帐号或者密码不正确,请重新输入。";
break;
case "-4":
i = "不存在该帐户。";
break;
case "-5":
i = "您目前处于访问受限状态。";
break;
case "-6":
i = "请输入图中的验证码",
r();
return;
case "-7":
i = "此帐号已绑定私人微信号,不可用于公众平台登录。";
break;
case "-8":
i = "邮箱已存在。";
break;
case "-32":
i = "您输入的验证码不正确,请重新输入",
r();
break;
case "-200":
i = "因频繁提交虚假资料,该帐号被拒绝登录。";
break;
case "-94":
i = "请使用邮箱登陆。";
break;
case "10":
i = "该公众会议号已经过期,无法再登录使用。";
break;
case "65201":
case "65202":
i = "成功登陆,正在跳转...",
location.href = t.ErrMsg;
return;
case "0":
i = "成功登陆,正在跳转...",
location.href = t.ErrMsg;
return;
default:
i = "未知的返回。";
return
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
呃,已经有个轮子了。
https://github.com/dodgepudding/wechat-php-sdk
你这个设置一下NAME = ""
PASSWORD = ""
成功了吗?
我自己设置了一下 还是不行