我正在尝试登录我的 Google 帐户。我读过旧文章使用HTTP-Fox获取所有参数。所以我添加了所有,包括隐藏的。
package com.businessLogic;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
public class Browser {
public static void main (String [] arg ){
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://accounts.google.com/ServiceLogin");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("service", "lso"));
nameValuePairs.add(new BasicNameValuePair("passive", "1209600"));
nameValuePairs.add(new BasicNameValuePair("continue", "https://accounts.google.com/o/oauth2/auth?....."));
nameValuePairs.add(new BasicNameValuePair("ltmpl", "embedded"));
nameValuePairs.add(new BasicNameValuePair("shdf", "CoMBCxIRdGhpcmR...."));
nameValuePairs.add(new BasicNameValuePair("scc", "1"));
nameValuePairs.add(new BasicNameValuePair("dsh", "-2602464068824153107"));
nameValuePairs.add(new BasicNameValuePair("GALX", "qqYU2P_8USM"));
nameValuePairs.add(new BasicNameValuePair("pstMsg", "1"));
nameValuePairs.add(new BasicNameValuePair("dnConn", ""));
nameValuePairs.add(new BasicNameValuePair("checkConnection", "youtube:816:1"));
nameValuePairs.add(new BasicNameValuePair("checkedDomains", "youtube"));
nameValuePairs.add(new BasicNameValuePair("timeStmp", ""));
nameValuePairs.add(new BasicNameValuePair("secTok", ""));
nameValuePairs.add(new BasicNameValuePair("_utf8", "â"));
nameValuePairs.add(new BasicNameValuePair("bgresponse", "!A0LfAt2vXHmPiURq..."));
nameValuePairs.add(new BasicNameValuePair("Email", "XXX"));
nameValuePairs.add(new BasicNameValuePair("Passwd", "XXX"));
nameValuePairs.add(new BasicNameValuePair("signIn", "Anmelden"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
回复:
<html><head><title>Google Accounts</title>
</head>
<body dir="ltr" bgcolor="#ffffff" text="#000000" link="#0000cc" vlink="#551a8b" alink="#ff0000">
<div class="topbar aligns" style="font-size:smaller; margin-bottom:0 15px 1px 15px; white-space:nowrap;">
<a>
Google Home
</a>
|
<a>Sign in</a></div>
<div class="header margins" style="height: 40px; margin: 13px 15px 9px 15px;"><a href="https://accounts.google.com/"><img src="/googleaccountslogo/en.gif" border="0" class="floats-normal" alt="Google"></a>
</div>
<div style="clear:both;"></div>
<div class="body"><p>Your browser's cookie functionality is turned off. Please turn it on.
[<a href="http://www.google.com/support/accounts/bin/answer.py?answer=61416&hl=en&ctx=ch_ServiceLogin&p=lso" target="_blank">?</a>]</p>
©2012 Google
</body></html>
登录失败。“登录”选项也可用。我不知道如何处理这些答案/Cookie。我找不到有用的解决方案,因为每个人都使用旧 API,httpclient
而org.apache.common.*
.
那你能帮帮我吗?