当前位置: 首页>>代码示例>>Java>>正文


Java HttpMethodParams.setContentCharset方法代码示例

本文整理汇总了Java中org.apache.commons.httpclient.params.HttpMethodParams.setContentCharset方法的典型用法代码示例。如果您正苦于以下问题:Java HttpMethodParams.setContentCharset方法的具体用法?Java HttpMethodParams.setContentCharset怎么用?Java HttpMethodParams.setContentCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.httpclient.params.HttpMethodParams的用法示例。


在下文中一共展示了HttpMethodParams.setContentCharset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendSms

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
/**
 * 发短信
 *
 * @param apikey apikey
 * @param text    短信内容
 * @param mobile  接受的手机号
 * @return json格式字符串
 * @throws IOException
 */
public static String sendSms(String apikey, String text, String mobile){
    HttpClient client = new HttpClient();
    NameValuePair[] nameValuePairs = new NameValuePair[3];
    nameValuePairs[0] = new NameValuePair("apikey", apikey);
    nameValuePairs[1] = new NameValuePair("text", text);
    nameValuePairs[2] = new NameValuePair("mobile", mobile);
    PostMethod method = new PostMethod(URI_SEND_SMS);
    method.setRequestBody(nameValuePairs);
    HttpMethodParams param = method.getParams();
    param.setContentCharset(ENCODING);

    try {
        client.executeMethod(method);
        return method.getResponseBodyAsString();
    } catch (IOException ex) {
        throw new RuntimeException("sendSms error", ex);
    } finally {
        method.releaseConnection();
        HttpConnectionManager connectionManager = client.getHttpConnectionManager();
        ((SimpleHttpConnectionManager)connectionManager).shutdown();
    }
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:32,代码来源:JavaSmsApi.java

示例2: post

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public Response post(String url, PostParameter[] params,
		Boolean WithTokenHeader, PostParameter[] headers)
		throws MxException {

	PostMethod postMethod = new PostMethod(url);
	for (int i = 0; i < params.length; i++) {
		String pValue = params[i].getValue();
		if (pValue != null) {
			postMethod.addParameter(params[i].getName(),
					params[i].getValue());
		}
	}
	HttpMethodParams param = postMethod.getParams();
	param.setContentCharset("UTF-8");
	if (WithTokenHeader) {

		return httpRequest(postMethod, headers);
	} else {

		return httpRequest(postMethod, WithTokenHeader, headers, null);
	}
}
 
开发者ID:dehuinet,项目名称:minxing_java_sdk,代码行数:23,代码来源:HttpClient.java

示例3: post

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public Response post(String url, PostParameter[] params,
		Boolean WithTokenHeader) throws WeiboException {
	log("Request:");
	log("POST" + url);
	PostMethod postMethod = new PostMethod(url);
	for (int i = 0; i < params.length; i++) {
		postMethod.addParameter(params[i].getName(), params[i].getValue());
	}
	HttpMethodParams param = postMethod.getParams();
	param.setContentCharset("UTF-8");
	if (WithTokenHeader) {
		return httpRequest(postMethod);
	} else {
		return httpRequest(postMethod, WithTokenHeader);
	}
}
 
开发者ID:chenhui5416,项目名称:sinaWeiboAutoReply,代码行数:17,代码来源:HttpClient.java

示例4: getUserInfo

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
/**
 * 取账户信息
 *
 * @return json格式字符串
 * @throws IOException
 */
public static String getUserInfo(String apikey) throws IOException {
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(URI_GET_USER_INFO + "?apikey=" + apikey);
    HttpMethodParams param = method.getParams();
    param.setContentCharset(ENCODING);
    client.executeMethod(method);
    return method.getResponseBodyAsString();
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:15,代码来源:JavaSmsApi.java

示例5: tplSendSms

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
/**
 * 通过模板发送短信
 *
 * @param apikey    apikey
 * @param tpl_id     模板id
 * @param tpl_value  模板变量值
 * @param mobile     接受的手机号
 * @return json格式字符串
 * @throws IOException
 */
public static String tplSendSms(String apikey, long tpl_id, String tpl_value, String mobile) throws IOException {
    HttpClient client = new HttpClient();
    NameValuePair[] nameValuePairs = new NameValuePair[4];
    nameValuePairs[0] = new NameValuePair("apikey", apikey);
    nameValuePairs[1] = new NameValuePair("tpl_id", String.valueOf(tpl_id));
    nameValuePairs[2] = new NameValuePair("tpl_value", tpl_value);
    nameValuePairs[3] = new NameValuePair("mobile", mobile);
    PostMethod method = new PostMethod(URI_TPL_SEND_SMS);
    method.setRequestBody(nameValuePairs);
    HttpMethodParams param = method.getParams();
    param.setContentCharset(ENCODING);
    client.executeMethod(method);
    return method.getResponseBodyAsString();
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:25,代码来源:JavaSmsApi.java

示例6: post

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public Response post(String url, PostParameter[] params,
		Boolean WithTokenHeader, String token) throws WeiboException {
	log("Request:");
	log("POST" + url);
	PostMethod postMethod = new PostMethod(url);
	for (int i = 0; i < params.length; i++) {
		postMethod.addParameter(params[i].getName(), params[i].getValue());
	}
	HttpMethodParams param = postMethod.getParams();
	param.setContentCharset("UTF-8");
	return httpRequest(postMethod, WithTokenHeader, token);
}
 
开发者ID:seagrape,项目名称:kekoa,代码行数:13,代码来源:HttpClient.java

示例7: post

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public Response post(String url, PostParameter[] params, Boolean WithTokenHeader, String token)
        throws WeiboException {
    log("Request:");
    log("POST" + url);
    PostMethod postMethod = new PostMethod(url);
    for (int i = 0; i < params.length; i++) {
        postMethod.addParameter(params[i].getName(), params[i].getValue());
    }
    HttpMethodParams param = postMethod.getParams();
    param.setContentCharset("UTF-8");
    return httpRequest(postMethod, WithTokenHeader, token);
}
 
开发者ID:jpbirdy,项目名称:WordsDetection,代码行数:13,代码来源:HttpClient.java

示例8: checkAmount

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
/**
 * 查询余额
 *
 * @return
 */
@Override
public String checkAmount() throws IOException {
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(URI_GET_USER_INFO + "?apikey=" + apikey);
    HttpMethodParams param = method.getParams();
    param.setContentCharset(ENCODING);
    client.executeMethod(method);
    String jsonBody = method.getResponseBodyAsString();
    return jsonBody;

}
 
开发者ID:thinkfree2015,项目名称:p00,代码行数:17,代码来源:YunPianSmsProvider.java

示例9: post

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public Response post(String url, PostParameter[] params, Boolean WithTokenHeader, PostParameter[] headers) throws MxException {
	log("Request:");
	log("POST:" + url);
	PostMethod postMethod = new PostMethod(url);
	for (int i = 0; i < params.length; i++) {
		postMethod.addParameter(params[i].getName(), params[i].getValue());
	}
	HttpMethodParams param = postMethod.getParams();
	param.setContentCharset("UTF-8");
	if (WithTokenHeader) {
		return httpRequest(postMethod, headers);
	} else {
		return httpRequest(postMethod, WithTokenHeader, headers);
	}
}
 
开发者ID:wangpeile,项目名称:mx-connector-1.5,代码行数:16,代码来源:HttpClient.java

示例10: getStandardizedPlaceNames

import org.apache.commons.httpclient.params.HttpMethodParams; //导入方法依赖的package包/类
public Map<String,String> getStandardizedPlaceNames(Set<String> names, PrintWriter err) throws IOException, SAXException, XPathExpressionException
{
   Map<String,String> result = new HashMap<String,String>();
   String query = Util.join("|", names);
   String url = "http://"+placeServer+"/placestandardize";
   PostMethod m = new PostMethod(url);
   NameValuePair[] nvp = new NameValuePair[2];
   nvp[0] = new NameValuePair("q", query);
   nvp[1] = new NameValuePair("wt", "xml");
   m.setRequestBody(nvp);
   HttpMethodParams params = new HttpMethodParams();
   params.setContentCharset("UTF-8");
   params.setHttpElementCharset("UTF-8");
   params.setParameter("http.protocol.content-charset", "UTF-8");
   m.setParams(params);
   m.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   int numTries = 0;
   while (numTries++ < 3) {
      try {
         client.executeMethod(m);
         break;
      }
      catch (IOException e) {
         resetClient();
      }
   }
   String response = m.getResponseBodyAsString();
   Document doc = db.parse(new InputSource(new StringReader(response)));
   NodeList lstNodes = (NodeList) lstExpression.evaluate(doc, XPathConstants.NODESET);
   for (int i=0; i < lstNodes.getLength(); i++)
   {
      Node node = lstNodes.item(i);
      String q = (String) queryExpression.evaluate(node, XPathConstants.STRING);
      String placeTitle = (String)placeTitleExpression.evaluate(node, XPathConstants.STRING);
      String error = (String) errorExpression.evaluate(node, XPathConstants.STRING);
      if (err != null && !Util.isEmpty(error)) {
         err.println(q);
      }
      placeTitle = getRedirTarget(placeTitle);
      result.put(q,placeTitle);
   }
   return result;
}
 
开发者ID:werelate,项目名称:wikidata,代码行数:44,代码来源:StandardizePlaces.java


注:本文中的org.apache.commons.httpclient.params.HttpMethodParams.setContentCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。