日期:2014-05-17  浏览次数:20515 次

微信公众平台模拟登陆问题
为了获得用户的头像和用户名,查了下相关资料,只有模拟登陆可以做到。
于是用snoopy模拟登陆代码如下

<?php 

include('Snoopy.class.php');

 function login(){
$snoopy = new Snoopy(); 
$submit = "http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
$post["username"] = '我的账号';
$post["pwd"] = substr(md5('我的密码'), 0,16);
echo $post["pwd"];
$post["f"] = "json";
$snoopy->submit($submit,$post);
$cookie = '';
print_r($snoopy->headers);exit;

 }
 login();
?>

获得的头部信息中没有set-cookie 登陆失败,请问,我这段程序错在哪里了?还是说最近微信改了他的代码了,我看微信公众平台上的登陆js也是post过去这几个内容

var createLoginForm = function(e) {
var t = jQuery, n = function() {
var e = !1;
inputs = m.getVal();
switch (!1) {
case !!inputs.account:
s.trigger("Warning", [ f, "你还没有输入帐号!" ]);
break;
case !!inputs.password:
s.trigger("Warning", [ l, "你还没有输入密码!" ]);
break;
case !!inputs.verify || !!c.data("isHide"):
s.trigger("Warning", [ h, "你还没有输入验证码!" ]), r();
break;
default:
e = !0;
}
return e;
}, r = function() {
h.val(""), p.attr("src", "/cgi-bin/verifycode?username=" + m.getVal().account + "&r=" + +(new Date));
}, i = e.selector, s = t(i.error), o = t(i.errorArea), u = t(i.rememberAcct), a = t(i.changeImgLink), f = t(i.account).keydown(function(e) {
e.keyCode == 13 && l.focus().select();
}), l = t(i.password).keydown(function(e) {
e.keyCode == 13 && d.click();
}), c = t(i.verifyArea).data("isHide", 1).hide(), h = t(i.verify).keydown(function(e) {
e.keyCode == 13 && (l.val() ? d.click() : l.focus().select());
}), p = t(i.verifyImg).click(r), d = t(i.loginBtn), v = function(e, t) {
return;
var n, r, i;
};
s.bind("Warning", function(e, t, n) {
o.removeClass("dn"), s.text(n).hide().fadeIn();
}), p.bind({
load: function() {
v([ f, l ]), c.show().data("isHide", 0), h.focus().select();
},
error: function() {}
}), s.bind("Response", function(e, t, n) {
o.removeClass("dn"), s.html(n).hide().fadeIn(), v([ f, l ], "N"), c.data("isHide") || r();
switch (t) {
case "-3":
l.focus().select();
break;
case "-6":
h.focus().select();
break;
default:
f.focus().select();
}
t != "-32" && l.val("");
});
var m = {
showVerifyImg: r,
submit: function() {
if (!n()) return;
var e = m.getVal();
t.post("/cgi-bin/login?lang=zh_CN", {
username: e.account,
pwd: t.md5(e.password.substr(0, 16)),
imgcode: c.data("isHide") ? "" : e.verify,
f: "json"
}, function(t) {
var n = t.ErrCode + "", i;
u.hasClass("checkbox_checked") ? WXM.Helpers.setCookie("remem