String url = "http://sgame.baidu.com/vertify_session.xhtml";
// 第一步,创建HttpPost对象
HttpPost httpPost = new HttpPost(url);
// 设置HTTP POST请求参数必须用NameValuePair对象
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("apiKey", LibClient.appid));
params.add(new BasicNameValuePair("sessionId", sessionID));
params.add(new BasicNameValuePair("sign", MD5(LibClient.appkey+LibClient.appid+sessionID)));
Log.d("params",params.toString());
HttpResponse httpResponse = null;
try {
// 设置httpPost请求参数
httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
httpResponse = new DefaultHttpClient().execute(httpPost);
//System.out.println(httpResponse.getStatusLine().getStatusCode());
if (httpResponse.getStatusLine().getStatusCode() == 200) {
// 第三步,使用getEntity方法活得返回结果
String result = EntityUtils.toString(httpResponse.getEntity());
System.out.println("result:" + result);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}