获取鸣叫具体包括hashtag从Android的使用布艺用户的时间线 [英] Getting tweets with specific hashtag from a user's timeline using Fabric in android
问题描述
我试图让鸣叫具体包括hashtag从用户的时间线(EX- @ kkajnabi#苏曼
)在Android中使用的面料。
I am trying to get tweets with specific hashtag from a user's timeline (ex- @kkajnabi#suman
) using Fabric in android.
我能够获得使用下面code从%23suman
推特(#苏曼)。但我希望从中获取鸣叫%40kkajnabi%23suman
(@ kkajnabi#苏曼)。
I am able to get tweets from %23suman
(#suman) using below code. But i want to get tweets from %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();
我觉得这种做法是错误的。任何人都plz帮助我在写作查询%40kkajnabi%23suman
或者有一些其他的方法来做到这一点。
I think this approach is wrong . Anyone plz help me on writing query for %40kkajnabi%23suman
or there is some other approach to do this.
推荐答案
这是一个有点粗糙,但这里是如何获得用户的tweet
It's a little rough, but here's how to get the user tweets
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);
}
});
那么我还能做什么,是一种快速的条件,以确定是否鸣叫对象包含要从实体属性的井号标签。 我需要用这个有点玩给你,你需要确切的答案。我看了看API,遗憾的是没有说法,我可以找到获取用户的时间线,并随后按标签过滤。所以,我想你会需要遍历。这里有一个很好的参考StatusesService类 HTTPS的userTimeline()方法:// twittercommunity .COM /吨/ Android的usertimeline个问题/二分之三万零二百六十三
Then what I would do, is a quick conditional to determine if the Tweet object contains the hashtags that you want from the entities attribute. I'll need to play with this a bit to give you the exact answer you need. I looked at the API, unfortunately there is no argument that I can find for getting a user's timeline and subsequently filtering by tag. So I think you'll need to iterate through. Here's a good reference to the userTimeline() method of the StatusesService class https://twittercommunity.com/t/android-usertimeline-question/30263/2
再者,我今天晚些时候有机会,我会更新这个答案
Again, I will update this answer when I have a chance later today
这篇关于获取鸣叫具体包括hashtag从Android的使用布艺用户的时间线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!