【问题标题】:Getting tweets with specific hashtag from a user's timeline using Fabric in android在 android 中使用 Fabric 从用户的时间轴获取带有特定主题标签的推文
【发布时间】:2015-10-11 23:01:56
【问题描述】:

我正在尝试使用 Android 中的 Fabric 从用户的时间线(例如@kkajnabi#suman)获取带有特定主题标签的推文。

我可以使用以下代码从%23suman(#suman) 获取推文。但我想收到来自%40kkajnabi%23suman(@kkajnabi#suman) 的推文。

public class TimelineActivity extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timeline);

        TwitterAuthConfig authConfig =  new TwitterAuthConfig("xxxxxxbbbbwdqddq", "eieuhquifhioqhfiohqoifhoi");
        Fabric.with((this), new TwitterCore(authConfig), new TweetUi());

        final SearchTimeline searchTimeline = new SearchTimeline.Builder()
                .query("%40kkajnabi%23suman")
                .build();

我认为这种做法是错误的。任何人请帮我编写%40kkajnabi%23suman 的查询,或者有其他方法可以做到这一点。

【问题讨论】:

  • 我不知道为什么有些人只是在没有给出任何理由的情况下对问题投反对票.....如果您无法发表评论,请不要对问题投反对票

标签: android twitter hashtag timeline twitter-fabric


【解决方案1】:

这有点粗糙,但这里是获取用户推文的方法

ArrayList<Tweet> tweets = new ArrayList<>();
TwitterCore.getInstance().getApiClient(session).getStatusesService()
    .userTimeline(null,
            "screenname",
            10 //the number of tweets we want to fetch,
            null,
            null,
            null,
            null,
            null,
            null,
            new Callback<List<Tweet>>() {
                @Override
                public void success(Result<List<Tweet>> result) {
                    for (Tweet t : result.data) {
                        tweets.add(t);
                        android.util.Log.d("twittercommunity", "tweet is " + t.text);
                    }
                }

                @Override
                public void failure(TwitterException exception) {
                    android.util.Log.d("twittercommunity", "exception " + exception);
                }
            });

然后我要做的是一个快速的条件来确定 Tweet 对象是否包含您想要从实体属性中获得的主题标签。 我需要稍微玩一下,才能为您提供所需的确切答案。我查看了 API,不幸的是,我找不到用于获取用户时间线并随后按标签过滤的参数。所以我认为你需要迭代。这里有一个很好的参考 StatusesService 类的 userTimeline() 方法https://twittercommunity.com/t/android-usertimeline-question/30263/2

再次,我将在今天晚些时候有机会时更新此答案

【讨论】:

    猜你喜欢
    • 2013-06-02
    • 2017-12-18
    • 2013-09-24
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 2015-03-02
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多