代码如下:
try {
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
ArrayList pairs = new ArrayList();
Set keys = params.keySet();
for(Iterator i = keys.iterator(); i.hasNext();) {
String key = (String)i.next();
pairs.add(new BasicNameValuePair(key, params.get(key)));
}
UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(pairs, "utf-8");
httpPost.setEntity(p_entity);
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
content = entity.getContent();
在执行到HttpResponse response = client.execute(httpPost); 就出错了,求大神看下,或者给个简单的例子。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
小伙看你根骨奇佳,潜力无限,来学PHP伐。