[英]How to get the via field in twitter using Twitter4j?
I am working on Twitter integration with android using Twitter4j library. 我正在使用Twitter4j库进行Twitter与Android的集成。 I have user access token and secrets and i am also able to get username and his/her tweets below is the code for this. 我有用户访问令牌和机密,我也能够获取用户名,下面的他/她的推文就是此代码。
AccessToken a = new AccessToken(tokens[0], tokens[1]);
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
Constants.CONSUMER_SECRET);
twitter.setOAuthAccessToken(a);
// twitter.updateStatus(msg);
List<Status> statuses = twitter.getFriendsTimeline();
System.out.println("Showing friends timeline.");
for (Status status : statuses) {
System.out.println(status.getUser().getName() + ":"
+ status.getText() + ":" + status.);
}
Now I want to fetch the Via field message which comes in some tweets but not able to do this please help me to do this I have also attached the screen shot what I want to fetch please look into this and give me any suggestion on this. 现在,我想获取某些推文中的“ Via”字段消息 ,但无法执行此操作,请帮助我执行此操作。我还附上了我想获取的屏幕快照,请仔细研究并给我任何建议。
Who retweeted the status shows up a little bit differently on the Twitter home page now. 谁转推了状态,现在在Twitter主页上的显示有所不同。
When I fetch and print the above status in Java using: 当我使用以下命令在Java中获取并打印上述状态时:
System.out.println(status.getUser().getName() + ":" + status.getText());
I get the following result: 我得到以下结果:
Stack Exchange:RT @StackGameDev: Should Vector3 inherit from Vector2? 堆栈交换:RT @StackGameDev:Vector3应该从Vector2继承吗? http://t.co/JZXXB6kr #architecture http://t.co/JZXXB6kr#体系结构
So, the User
who retweeted the status can be read directly using the status.getUser()
method. 因此,可以使用status.getUser()
方法直接读取转发状态的User
。
The user who originally posted the tweet is a little bit trickier to get. 最初发布该推文的用户会有点棘手。 There is no method (that I could find) to directly read the original poster, but you can see from the example above that Twitter prepends the user's name to the text of the message ("RT @StackGameDev: " in the example). 没有(我可以找到)直接阅读原始海报的方法,但是您可以从上面的示例中看到Twitter将用户名添加到消息的文本之前(示例中为“ RT @StackGameDev:”)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.