叽叽喳喳的Andr​​oid用户/显示(用户信息)的迁移版本1到1.1 [英] Android twitter user/show (user information) migration version 1 to 1.1

查看:225
本文介绍了叽叽喳喳的Andr​​oid用户/显示(用户信息)的迁移版本1到1.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,集成了Twitter的。

In my Android application, have integrated Twitter.

我已经改变了用户/显示API版本1到1.1版本。新的API不工作,这让400 - 错误请求异常。我花了很多时间来解决,但无法找出解决方案。

I have changed the user/show api version 1 to version 1.1. The new api is not working and it gives 400 - Bad request exception. I have spend a lot of time to resolve but unable to find out the solution.

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 include_entities = FALSE

提到Twitter的开发者网站:
这里输入链接的描述

Referred the twitter developer site: enter link description here

在我的code,我使用HTTP GET方法来获取从API JSON响应。

In my code I am using http GET method to get json response from the api.

code样品:<​​/ P>

code sample:

        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

请帮我解决这个问题。

推荐答案

我已经通过API发送认证解决我的问题。

I have solved my problem by sending authentication with api.

在API 1.1版本,我们需要发送与请求验证,否则我们得到400错误的请求(无效的请求)。

In api version 1.1 we need to send authentication with request otherwise we get 400 bad request(invalid request).

这是发送认证编码的例子。

This is the coding example for sending authentication.

private OAuthConsumer consumer;

consumer = new CommonsHttpOAuthConsumer(
Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);

consumer.setTokenWithSecret(token,secret_token);

..........

..........

HttpGet httpGet = new HttpGet(params[0]);
consumer.sign(hpost);

我们需要签核,并签署共同岗位罐。

we need sign-core and sign common post jars.

这篇关于叽叽喳喳的Andr​​oid用户/显示(用户信息)的迁移版本1到1.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆