AndroidでAPIupvote
を使用して質問しようとしています。stackexchange
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();
}