我正在尝试upvote
使用stackexchange
android 中的 API 提出问题。使用 URL
https://api.stackexchange.com/2.2/questions/{questionID}/upvote
但在日志中它只是显示类似 org.apache.http.message.BasicHttpResponse@33b2c539
支持问题的 API 链接是 https://api.stackexchange.com/docs/upvote-question
当我从 API 链接尝试它的工作时,但不是使用代码。
在下面的代码中找到:
字符串 url="https://api.stackexchange.com/2.2/questions/"+questionId+"/upvote";
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url.toString());
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("key", key));
nameValuePair.add(new BasicNameValuePair("access_token", accessToken));
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// making request
try {
response = httpClient.execute(httpPost);
Log.d("Http Post Response:", response.toString());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}