玩蛇网提供最新Python编程技术信息以及Python资源下载!

Python 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

呃,已经有个轮子了。

https://github.com/dodgepudding/wechat-php-sdk

你这个设置一下NAME = "" PASSWORD = "" 成功了吗? 我自己设置了一下 还是不行

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/wenda/wd20121.html

相关文章 Recommend

玩蛇网Python互助QQ群,欢迎加入-->: 106381465 玩蛇网Python新手群
修订日期:2017年05月27日 - 11时22分31秒 发布自玩蛇网

您现在的位置: 玩蛇网首页 > Python问题解答 > 正文内容
我要分享到:

必知PYTHON教程 Must Know PYTHON Tutorials

必知PYTHON模块 Must Know PYTHON Modules