在我的 Android 应用程序中,已经集成了 Twitter。
我已将 user/show api version 1 更改为 version 1.1。新的 api 不起作用,它给出 400 - 错误请求异常。我花了很多时间来解决,但无法找到解决方案。
version 1 api for user/show:
"https://api.twitter.com/1/users/show.json?user_id="+userID+"&include_entities=true"
version 1.1 api for user/show:
"https://api.twitter.com/1.1/users/show.json?user_id="+userID+"&include_entities=true"
我试过没有include_entities=true
and include_entities=false
。
参考 twitter 开发者网站: 在此处输入链接描述
在我的代码中,我使用 http GET 方法从 api 获取 json 响应。
代码示例:
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(params[0]);
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
----------
} else {
Log.e("Server code ", statusCode + " * " + statusLine+" Failed to download");
}
Exception I get:
Server code(460): 400 * HTTP/1.1 400 Bad Request Failed to download
请帮我解决问题。