标签:tpc new ring _id post air gets name eva
public static String post(String url) throws Exception {
//建立HttpPost对象
HttpPost httppost = new HttpPost(url);
//建立一个NameValuePair数组,用于存储欲传送的参数
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("grant_type", "client_credentials"));
params.add(new BasicNameValuePair("client_id", "xxxxxxxx"));
params.add(new BasicNameValuePair("client_secret", "290bb6573f478755ba369daf78cdbe92"));
//设置编码
httppost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = new DefaultHttpClient().execute(httppost);
//发送Post,并返回一个HttpResponse对象
if (response.getStatusLine().getStatusCode() == 200) {//如果状态码为200,就是正常返回
String result = EntityUtils.toString(response.getEntity());
return result;
}
return response.getStatusLine().getStatusCode() + "";
}
标签:tpc new ring _id post air gets name eva
原文地址:https://www.cnblogs.com/sunvooker/p/9296604.html