String httpUrl = "http://apicn.faceplusplus.com/v2/detection/landmark";
//HttpPost连接对象
HttpPost httpRequest = new HttpPost(httpUrl);
//使用NameValuePair来保存要传递的Post参数
List<NameValuePair> params = new ArrayList<NameValuePair>();
//添加要传递的参数
params.add(new BasicNameValuePair("api_key", APIKEY));
params.add(new BasicNameValuePair("api_secret", API_SECRET));
params.add(new BasicNameValuePair("face_id", faceid));
//设置字符集
HttpEntity httpentity;
try {
httpentity = new UrlEncodedFormEntity(params, "utf-8");
httpRequest.setEntity(httpentity);
//取得默认的HttpClient
HttpClient httpclient = new DefaultHttpClient();
//取得HttpResponse
HttpResponse httpResponse = httpclient.execute(httpRequest);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
//取得返回的字符串
String strResult = EntityUtils.toString(httpResponse.getEntity());
sb.append(strResult);
}
else
{
Log.i("wangchao","请求错误!");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//请求httpRequest
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
//HttpStatus.SC_OK表示连接成功