本文整理汇总了Java中org.apache.http.message.BasicNameValuePair类的典型用法代码示例。如果您正苦于以下问题:Java BasicNameValuePair类的具体用法?Java BasicNameValuePair怎么用?Java BasicNameValuePair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicNameValuePair类属于org.apache.http.message包,在下文中一共展示了BasicNameValuePair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPostParameterPairs
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
@SuppressWarnings("unused")
private static List<NameValuePair> getPostParameterPairs(Map<String, String> postParams) {
List<NameValuePair> result = new ArrayList<NameValuePair>(postParams.size());
for (String key : postParams.keySet()) {
result.add(new BasicNameValuePair(key, postParams.get(key)));
}
return result;
}
示例2: s_sendMobile
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
@Deprecated
public String s_sendMobile(int updataId, String mobile, String ver, String Cookid) {
String requestUrl;
if (PreferencesManager.getInstance().isTestApi() && LetvConfig.isForTest()) {
requestUrl = "http://test2.m.letv.com/android/dynamic.php";
} else {
requestUrl = "http://dynamic.user.app.m.letv.com/android/dynamic.php";
}
String str = MD5.toMd5("action=reg&mobile=" + mobile + "&pcode=" + LetvConfig.getPcode() + "&plat=mobile_tv" + "&version=" + LetvUtils.getClientVersionName() + "&poi345");
List<BasicNameValuePair> list = new ArrayList();
list.add(new BasicNameValuePair("mod", MODIFYPWD_PARAMETERS.MOD_VALUE));
list.add(new BasicNameValuePair("ctl", "clientSendMsg"));
list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
list.add(new BasicNameValuePair("mobile", mobile));
list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.PLAT_KEY, "mobile_tv"));
list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.APISIGN_KEY, str));
list.add(new BasicNameValuePair("action", "reg"));
list.add(new BasicNameValuePair("captchaValue", ver));
list.add(new BasicNameValuePair("captchaId", Cookid));
list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
Log.e("ZSM", "s_sendMobile url == " + ParameterBuilder.getQueryUrl(list, requestUrl));
return ParameterBuilder.getQueryUrl(list, requestUrl);
}
示例3: register
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public static String register(String email_addr, String nick_name, String pwd) throws Exception {
HttpClient task_post = new DefaultHttpClient();
HttpPost post = new HttpPost(url + "/Register");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("email_addr", email_addr));
params.add(new BasicNameValuePair("nick_name", nick_name));
params.add(new BasicNameValuePair("pwd", pwd));
post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = task_post.execute(post);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = null;
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
result = EntityUtils.toString(httpEntity);
}
JSONObject jsonObject = new JSONObject(result);
int register_status = jsonObject.getInt("register_status");
int user_id = jsonObject.getInt("user_id");
if (register_status == 1)
return "SUCCESS,your user_id is " + String.valueOf(user_id);
else
return "FAIL";
}
return "401 UNAUTHORIZED";
}
示例4: getChatRecords
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public String getChatRecords(String roomId, boolean server, String tm, int mode) {
String keyb = roomId + "," + tm + "," + LetvConstant.CHAT_KEY;
ArrayList<BasicNameValuePair> params = new ArrayList();
params.add(new BasicNameValuePair("luamod", "main"));
params.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
params.add(new BasicNameValuePair("ctl", "chatGethistory"));
params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
params.add(new BasicNameValuePair("roomId", roomId));
params.add(new BasicNameValuePair("server", String.valueOf(server)));
params.add(new BasicNameValuePair("tm", tm));
params.add(new BasicNameValuePair("key", MD5.toMd5(keyb)));
params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
if (mode == 0) {
params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
} else {
params.add(new BasicNameValuePair("version", "6.0"));
}
LogInfo.log("clf", "获取历史聊天记录requestChatRecords..url=" + ParameterBuilder.getQueryUrl(params, getDynamicUrl()));
return ParameterBuilder.getQueryUrl(params, getDynamicUrl());
}
示例5: doPost
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
示例6: submitRemote
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
private void submitRemote(ThreePidSession session, String token) {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
Arrays.asList(
new BasicNameValuePair("sid", session.getRemoteId()),
new BasicNameValuePair("client_secret", session.getRemoteSecret()),
new BasicNameValuePair("token", token)
), StandardCharsets.UTF_8);
HttpPost submitReq = new HttpPost(session.getRemoteServer() + "/_matrix/identity/api/v1/submitToken");
submitReq.setEntity(entity);
try (CloseableHttpResponse response = client.execute(submitReq)) {
JsonObject o = new GsonParser().parse(response.getEntity().getContent());
if (!o.has("success") || !o.get("success").getAsBoolean()) {
String errcode = o.get("errcode").getAsString();
throw new RemoteIdentityServerException(errcode + ": " + o.get("error").getAsString());
}
log.info("Successfully submitted validation token for {} to {}", session.getThreePid(), session.getRemoteServer());
} catch (IOException e) {
throw new RemoteIdentityServerException(e.getMessage());
}
}
示例7: requestPraiseInfo
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public static String requestPraiseInfo(int updataId) {
String baseUrl = getUserDynamicUrl();
String uid = LetvUtils.getUID();
String userName = LetvUtils.getLoginUserName();
String deviceId = LetvUtils.generateDeviceId(BaseApplication.getInstance());
StringBuilder md5Sb = new StringBuilder();
md5Sb.append("uid=" + uid + "&");
md5Sb.append("username=" + userName + "&");
md5Sb.append("devid=" + deviceId + "&");
md5Sb.append("pcode=" + LetvConfig.getPcode() + "&");
md5Sb.append("version=" + LetvUtils.getClientVersionName() + "&");
md5Sb.append("letvpraise2014");
String md5Sign = MD5.toMd5(md5Sb.toString());
ArrayList<BasicNameValuePair> params = new ArrayList();
params.add(new BasicNameValuePair("mod", "passport"));
params.add(new BasicNameValuePair("ctl", "index"));
params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "praiseactivity"));
params.add(new BasicNameValuePair("uid", uid));
params.add(new BasicNameValuePair("username", userName));
params.add(new BasicNameValuePair(HOME_RECOMMEND_PARAMETERS.DEVICEID_KEY, deviceId));
params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
params.add(new BasicNameValuePair(TradeInfo.SIGN, md5Sign));
return ParameterBuilder.getQueryUrl(params, baseUrl);
}
示例8: deletePlayTraces
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public String deletePlayTraces(int updataId, String pid, String vid, String uid, String idstr, String flush, String backdata, String sso_tk) {
String baseUrl = UrlConstdata.getDynamicUrl();
List<BasicNameValuePair> list = new ArrayList();
list.add(new BasicNameValuePair("mod", "minfo"));
list.add(new BasicNameValuePair("ctl", "cloud"));
list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "del"));
list.add(new BasicNameValuePair("pid", pid));
list.add(new BasicNameValuePair("vid", vid));
list.add(new BasicNameValuePair("uid", uid));
list.add(new BasicNameValuePair("idstr", idstr));
list.add(new BasicNameValuePair("flush", flush));
list.add(new BasicNameValuePair("backdata", backdata));
list.add(new BasicNameValuePair("sso_tk", sso_tk));
list.add(new BasicNameValuePair("pcode", LetvHttpApiConfig.PCODE));
list.add(new BasicNameValuePair("version", LetvHttpApiConfig.VERSION));
return ParameterBuilder.getQueryUrl(list, baseUrl);
}
示例9: doMyResourcesSearch
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
private JsonNode doMyResourcesSearch(String query, String subsearch, Map<?, ?> otherParams, String token)
throws Exception
{
List<NameValuePair> params = Lists.newArrayList();
if( query != null )
{
params.add(new BasicNameValuePair("q", query));
}
for( Entry<?, ?> entry : otherParams.entrySet() )
{
params.add(new BasicNameValuePair(entry.getKey().toString(), entry.getValue().toString()));
}
// params.add(new BasicNameValuePair("token",
// TokenSecurity.createSecureToken(username, "token", "token", null)));
String paramString = URLEncodedUtils.format(params, "UTF-8");
HttpGet get = new HttpGet(context.getBaseUrl() + "api/search/myresources/" + subsearch + "?" + paramString);
HttpResponse response = execute(get, false, token);
return mapper.readTree(response.getEntity().getContent());
}
示例10: ipSend
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
/**
* send current ip to server
*/
private String ipSend() throws Exception {
HttpClient ip_send = new DefaultHttpClient();
HttpPost post = new HttpPost(url + "/UploadIP");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("machine_id", String.valueOf(machine_id)));
params.add(new BasicNameValuePair("ip", ip));
post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse httpResponse = ip_send.execute(post);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = null;
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null) {
result = EntityUtils.toString(httpEntity);
}
JSONObject jsonObject = new JSONObject(result);
int ip_save = jsonObject.getInt("ip_save");
if (ip_save == 1) {
return "SUCCESS";
} else return "FAIL";
}
return "401 UNAUTHORIZED";
}
示例11: loginWeixin
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public String loginWeixin(int updataId, String accessToken, String openId, String plat, String equipType, String equipID, String softID, String pcode, String version) {
String baseUrl = UrlConstdata.getDynamicUrl();
List<BasicNameValuePair> list = new ArrayList();
list.add(new BasicNameValuePair("luamod", "main"));
list.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
list.add(new BasicNameValuePair("ctl", "appssoweixin"));
list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
list.add(new BasicNameValuePair("access_token", accessToken));
list.add(new BasicNameValuePair("openid", openId));
list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.PLAT_KEY, plat));
list.add(new BasicNameValuePair("equipID", equipID));
list.add(new BasicNameValuePair("softID", softID));
list.add(new BasicNameValuePair("pcode", pcode));
list.add(new BasicNameValuePair("version", version));
list.add(new BasicNameValuePair("imei", LetvUtils.getIMEI()));
list.add(new BasicNameValuePair("mac", LetvUtils.getMacAddressForLogin()));
return ParameterBuilder.getQueryUrl(list, baseUrl);
}
示例12: getAlbumByTimeUrl
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public static String getAlbumByTimeUrl(String year, String month, String id, String videoType) {
String head = getStaticHead() + "/mod/mob/ctl/videolistbydate/act/detail";
String end = LetvHttpApiConfig.getStaticEnd();
ArrayList<BasicNameValuePair> params = new ArrayList();
params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
params.add(new BasicNameValuePair("pcode", LetvUtils.getPcode()));
if (!TextUtils.isEmpty(year)) {
params.add(new BasicNameValuePair("year", year));
}
if (!TextUtils.isEmpty(month)) {
params.add(new BasicNameValuePair("month", month));
}
params.add(new BasicNameValuePair("id", id));
if (!TextUtils.isEmpty(videoType)) {
params.add(new BasicNameValuePair(PlayConstant.VIDEO_TYPE, videoType));
}
return ParameterBuilder.getPathUrl(params, head, end);
}
示例13: resetPwd
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public static String resetPwd(int user_id, String pwd) throws Exception {
HttpClient task_post = new DefaultHttpClient();
HttpPost post = new HttpPost(url + "/ResetPwd");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("user_id", String.valueOf(user_id)));
params.add(new BasicNameValuePair("pwd", pwd));
post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = task_post.execute(post);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String result = null;
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
result = EntityUtils.toString(httpEntity);
}
JSONObject jsonObject = new JSONObject(result);
int pwd_reset = jsonObject.getInt("pwd_reset");
if (pwd_reset == 1)
return "SUCCESS";
else
return "FAIL";
}
return "401 UNAUTHORIZED";
}
示例14: PostConnect
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
public String PostConnect(String httpUrl, String str) {
String resultData = "";
HttpPost httpPost = new HttpPost(httpUrl);
List<NameValuePair> params = new ArrayList();
params.add(new BasicNameValuePair("data", str));
try {
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
resultData = EntityUtils.toString(httpResponse.getEntity());
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
return resultData;
}
示例15: getList
import org.apache.http.message.BasicNameValuePair; //导入依赖的package包/类
private List<NameValuePair> getList(Map<String, List<Object>> parameters) {
List<NameValuePair> result = new ArrayList<NameValuePair>();
if (parameters != null) {
TreeMap<String, List<Object>> sortedParameters = new TreeMap<String, List<Object>>(parameters);
for (Map.Entry<String, List<Object>> entry : sortedParameters.entrySet()) {
List<Object> entryValue = entry.getValue();
if (entryValue != null) {
for (Object cur : entryValue) {
if (cur != null) {
result.add(new BasicNameValuePair(entry.getKey(), cur.toString()));
}
}
}
}
}
return result;
}