1.方式一
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(Url);
client.getParams().setContentCharset("GBK");
method.setRequestHeader("ContentType","application/x-www-form-urlencoded;charset=GBK");
//解析ConnectionString时存储并串联Name/Value对。
NameValuePair[] data = {//提交验证信息
new NameValuePair("grant_type", "client_credential"),
new NameValuePair("appid", "自己的appid"),
new NameValuePair("secret","自己的secret"),
};
method.setRequestBody(data);
client.executeMethod(method);
String SubmitResult =method.getResponseBodyAsString();
System.out.println(SubmitResult);
JSONObject jsonobj=JSONObject.fromObject(SubmitResult);//将字符串转化成json对象