我想運行一個cURL命令到我的android應用程序,但我不知道如何。 這是示例命令:在Android應用程序的cURL命令
curl --data "[email protected]&pass=azerty" http://www.website.com/login/
我想運行一個cURL命令到我的android應用程序,但我不知道如何。 這是示例命令:在Android應用程序的cURL命令
curl --data "[email protected]&pass=azerty" http://www.website.com/login/
謝謝大家,我發現這個解決方案:
new Thread(new Runnable() {
@Override
public void run() {
final HttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, true);
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"http://wwwebsite.com/login/");
String HTML = "";
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
3);
nameValuePairs.add(new BasicNameValuePair("mail","[email protected]"));
nameValuePairs.add(new BasicNameValuePair("pass", "azerty"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HTML = EntityUtils.toString(response.getEntity());
if (response.getEntity() != null) {
Log.i("RESPONSE", HTML.toString());
}
} catch (ClientProtocolException e) {
Log.e("ee","ee");
} catch (IOException e) {
Log.e("ee","ee");
}
}
}).start();
你正在尋找一個HTTP客戶端。 – SLaks
我不知道如何用CURL調用 –
這可能是http://stackoverflow.com/questions/20782140/convert-curl-command-into-java-android –