2013年11月19日星期二

Micro-channel public platform on October 29th revision simulated landing affect you ?

If that.
I was doing java achieve simulated landing micro-channel public platform , not on the landing , there is always the server requests a timeout exception .
look great God who rescued ! !
------ Solution ---------------------------------------- ----
I also do this
------ For reference only -------------------------- -------------

great God who , where to go birds. . ?
------ For reference only -------------------------------------- -
landing looks like you can, but send a message to a user have a problem. . . . . .
------ For reference only -------------------------------------- -
problem has been resolved, but could not bear stickers,
who come there points.
first one out
------ For reference only ---------------------------------------


------ For reference only ---------------------------------------
landlord can say how to solve the next do ? Encountered the same problem , now is the login succeeded , but it did not get to take the user information . What is the reason ?
------ For reference only -------------------------------------- -
solving the problem is still not resolved. . . Thank you
------ For reference only ---------------------------------------
Results posted solutions when not given Tell me the way I am sorry . .
posts in the past several days, and specifically what factors influence I do not remember.
mainly to grasp the following three points:
1. whether you use a proxy server . 2 links there is no problem. 3 parameters are no problem.
This is my code in two ways successful landing
a .

public static String TOKEN;
public static Map<String, String> cookies;
public static String LOGIN_URL = "http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
public static String SEND_MSG = "http://mp.weixin.qq.com/cgi-bin/singlesend?t=ajax-response&lang=zh_CN";
public final static String USER_AGENT_H = "User-Agent";
public final static String USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22";
public final static String REFERER_H = "Referer";
public final static String INDEX_URL = "http://mp.weixin.qq.com/cgi-bin/indexpage?t=wxm-index&lang=zh_CN";
public final static String INDEX_URL2 = "https://mp.weixin.qq.com/";
          /**
 * 获取登录session
 * @return
 */
public static void auth(String username, String password) throws IOException {
Map<String, String> map = new HashMap<String, String>();
map.put("username", username);
map.put("pwd", MD5.getMD5(password.substring(0, password.length()).getBytes()).toUpperCase());
map.put("f", "json");
map.put("imagecode", "");

Response response = Jsoup.connect(LOGIN_URL).header(USER_AGENT_H, USER_AGENT).header(REFERER_H, INDEX_URL2).ignoreContentType(true)
.method(Method.POST).data(map).execute();
// Map<String, String> cookies = response.cookies();


//新添加代码
String json = response.body();
System.out.println(json);

Gson gson = new Gson();
WeiXinResponse weiXinResponse = gson.fromJson(json, WeiXinResponse.class);
String errMsg = weiXinResponse.getErrMsg();
TOKEN = errMsg.substring(errMsg.lastIndexOf("=")+1, errMsg.length());
cookies = response.cookies();


// return cookies;
}



two .
/ **
* send login information, records cookie, login status , token and other information
*
* @ return
* /
public boolean login () {
try {
PostMethod post = new PostMethod (LOGIN_URL);
post.setRequestHeader (USER_AGENT_H, USER_AGENT);
post.setRequestHeader (REFERER_H, INDEX_URL);
post.setRequestHeader (REFERER_H, INDEX_URL);
NameValuePair [] params = new NameValuePair [] {
new NameValuePair (" username ", this.loginUser),
new NameValuePair (" pwd ", DigestUtils.md5Hex (this.loginPwd
. getBytes ())), new NameValuePair ("f", "json"),
new NameValuePair (" imagecode "," ")};
post.setQueryString (params);
client.getHostConfiguration (). setProxy ("172.19.196.252", 8080);
int status = client.executeMethod (post);
if (status == HttpStatus.SC_OK) {
String ret = post.getResponseBodyAsString ();
LoginJson retcode = JSON.parseObject (ret, ; LoginJson.class);
System.out.println (retcode.getRet ());
if (retcode.getRet () == 302 && retcode.getErrCode () == 0) {
this.cookies = ; client.getState (). getCookies ();
StringBuffer cookie = ; new StringBuffer ();
for (Cookie c ;: client.getState (). getCookies ()) {
cookie.append (c.getName ()). append ("=")
. append (c.getValue ()). append (";");
}
this.cookiestr = ; cookie.toString ();
this.isLogin = ; true;
this.token = ; getToken (retcode.getErrMsg ());
return true;
}
int errCode = retcode.getErrCode ();
this.loginErrCode = errCode;
switch (errCode) {

case -1:
this.loginErrMsg = " system error" ;
return false;
case -2:
this.loginErrMsg = " username or password is incorrect " ;
return false;
case -3:
this.loginErrMsg = " wrong password" ;
return false;
case -4:
this.loginErrMsg = " the account does not exist " ;
return false;
case -5:
this.loginErrMsg = " limited access " ;
return false;
case -6:
this.loginErrMsg = " need to enter a verification code" ;
return false;
case -7:
this.loginErrMsg = " this account has been bound private micro Signal , not for the public platform login " ;
return false;
case -8:
this.loginErrMsg = " mailbox already exists" ;
return false;
case -32:
this.loginErrMsg = " verification code input errors " ;
return false;
case -200:
this.loginErrMsg = " due to frequent submitted false information , the account is denied login " ;
return false;
case -94:
this.loginErrMsg = " Please use the E-mail " ;
return false;
case 10:
this.loginErrMsg = " the number of public meetings has expired and can no longer log in using the" ;
return false;
case 65201:
case 65202:
this.loginErrMsg = " successful landing , is to jump ... " ;
return true;
case 0:
this.loginErrMsg = " successful landing , is to jump ... " ;
return true;
default:
this.loginErrMsg = " unknown returns" ;
return false;
}
}
} catch (Exception e) {
String info = " [ ] [ Login failed exception occurred :" + e.getMessage () + " ] " ;
System.err.println (info);
log.debug (info);
log.info (info);
return false;
}
return false;
}

没有评论:

发表评论