【问题标题】:Getting last tweet on android (API 1.1)在 android (API 1.1) 上获取最后一条推文
【发布时间】:2013-06-27 19:17:39
【问题描述】:

我正在使用以下方法制作安卓应用:

public JSONObject lastTweet(String username) throws ClientProtocolException, IOException, JSONException {
    String url = "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=hodorhodorhodor";
    HttpClient client = new DefaultHttpClient();    
    HttpGet get = new HttpGet(url);
    HttpResponse response = client.execute(get); //cannot execute this line
    int status = response.getStatusLine().getStatusCode();
    //Some more code
}

当我运行应用程序时,我收到应用程序已停止运行的错误消息。经过一些调试,我发现以下是我的应用卡住的行(我在上面的代码中也提到过):

HttpResponse response = client.execute(get);

在网上搜索后,我发现它必须与 twitter API 1.1 做一些事情,这需要某种 OAuth 身份验证。任何人都可以在这里帮助我吗?

谢谢。

【问题讨论】:

    标签: android twitter androidhttpclient


    【解决方案1】:

    As previously discussed on official Twitter forums,现在需要对 API 1.1 中的所有方法使用 OAuth,这会留下一些限制。

    您可以使用this library 接收访问令牌,如库中所述:只需实现 TwitterOAuthView.Listener 并调用 start() 方法。

    This blog post 是关于使用 twitter 访问令牌登录和编写 twitter 更新的完整教程。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2013-01-03
      • 2012-09-05
      • 2013-06-07
      • 2014-02-13
      • 1970-01-01
      • 2015-11-08
      • 2012-12-05
      • 2012-12-01
      相关资源
      最近更新 更多