【发布时间】:2014-08-05 16:25:31
【问题描述】:
在我的 Android 应用程序中,我使用的是 okHttp 库。如何使用 okhttp 库将参数发送到服务器(api)?目前我正在使用以下代码访问服务器现在需要使用okhttp库。
这是我的代码:
httpPost = new HttpPost("http://xxx.xxx.xxx.xx/user/login.json");
nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("email".trim(), emailID));
nameValuePairs.add(new BasicNameValuePair("password".trim(), passWord));
httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response = new DefaultHttpClient().execute(httpPost, new BasicResponseHandler());
【问题讨论】: