Skip to content

Instantly share code, notes, and snippets.

@liujbo
Last active October 25, 2017 01:08
Show Gist options
  • Save liujbo/ab35904faaa9c8eb77127bcd6025525d to your computer and use it in GitHub Desktop.
Save liujbo/ab35904faaa9c8eb77127bcd6025525d to your computer and use it in GitHub Desktop.
HTTP请求传入参数示例
maven依赖:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("account", SmsConstant.SMS_USERNAME));
params.add(new BasicNameValuePair("pswd",SmsConstant.SMS_PASSWORD));
params.add(new BasicNameValuePair("mobile",mobile));
params.add(new BasicNameValuePair("msg",message));
params.add(new BasicNameValuePair("needstatus","false"));
//调用HttpUtil工具类
String response = HttpUtil.doPost(SmsConstant.SMS_URL,params);
String [] responses = response.split(",");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment