我正在使用登录/通过发出 POST 请求并使用 Intent 打开站点。该站点正在打开,但未登录。出了什么问题?
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://mysite.co/login.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("pass", "mypass"));
nameValuePairs.add(new BasicNameValuePair("user", "myuser"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://mysite.com"));
startActivity(browserIntent);