本文整理了Java中twitter4j.Status.getUser()
方法的一些代码示例,展示了Status.getUser()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.getUser()
方法的具体详情如下:
包路径:twitter4j.Status
类名称:Status
方法名:getUser
[英]Return the user associated with the status.
This can be null if the instance is from User.getStatus().
[中]返回与状态关联的用户。
如果实例来自用户,则该值可以为null。getStatus()。
代码示例来源:origin: apache/incubator-druid
theMap.put("retweet_count", original.getRetweetCount());
User originator = original.getUser();
theMap.put("originator_screen_name", originator != null ? originator.getScreenName() : "");
theMap.put("originator_follower_count", originator != null ? originator.getFollowersCount() : "");
User user = status.getUser();
final boolean hasUser = (null != user);
theMap.put("follower_count", hasUser ? user.getFollowersCount() : 0);
代码示例来源:origin: stackoverflow.com
Status status;
String url= "https://twitter.com/" + status.getUser().getScreenName()
+ "/status/" + status.getId();
System.out.println(url);
代码示例来源:origin: apache/flume
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) {
User user = status.getUser();
Record doc = new Record(avroSchema);
doc.put("id", idPrefix + status.getId());
doc.put("created_at", formatterTo.format(status.getCreatedAt()));
doc.put("retweet_count", status.getRetweetCount());
doc.put("retweeted", status.isRetweet());
doc.put("in_reply_to_user_id", status.getInReplyToUserId());
doc.put("in_reply_to_status_id", status.getInReplyToStatusId());
addString(doc, "source", status.getSource());
addString(doc, "text", status.getText());
MediaEntity[] mediaEntities = status.getMediaEntities();
if (mediaEntities.length > 0) {
addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps());
addString(doc, "expanded_url", mediaEntities[0].getExpandedURL());
}
doc.put("user_friends_count", user.getFriendsCount());
doc.put("user_statuses_count", user.getStatusesCount());
doc.put("user_followers_count", user.getFollowersCount());
addString(doc, "user_location", user.getLocation());
addString(doc, "user_description", user.getDescription());
addString(doc, "user_screen_name", user.getScreenName());
addString(doc, "user_name", user.getName());
return doc;
}
代码示例来源:origin: pulsarIO/realtime-analytics
@Override
public void onStatus(Status status) {
HashtagEntity[] hashtagEntities = status.getHashtagEntities();
JetstreamEvent event = new JetstreamEvent();
event.setEventType("TwitterSample");
Place place = status.getPlace();
if (place != null) {
event.put("country", place.getCountry());
}
event.put("ct", status.getCreatedAt().getTime());
event.put("text", status.getText());
event.put("lang", status.getLang());
event.put("user", status.getUser().getName());
if (hashtagEntities != null && hashtagEntities.length > 0) {
StringBuilder s = new StringBuilder();
s.append(hashtagEntities[0].getText());
for (int i = 1; i < hashtagEntities.length; i++) {
s.append(",");
s.append(hashtagEntities[i].getText());
}
event.put("hashtag", s.toString());
}
fireSendEvent(event);
}
代码示例来源:origin: stackoverflow.com
try {
ResponseList<Status> a = twitter.getHomeTimeline(new Paging(1,1000));
for (Status b: a){
long userId = b.getUser().getId();// user Id
String userName = b.getUser().getName(); // user name
String tweetText = b.getText(); // tweet
System.out.println(userId+" "+userName+" "+tweetText);
}
}
代码示例来源:origin: stackoverflow.com
@SuppressWarnings("deprecation")
@Override
public void onStatus(Status status) {
System.out.println("@" + status.getUser().getScreenName()
+ " - " + status.getText());
tweetQueue.offer(DataObjectFactory.getRawJSON(status));
}
代码示例来源:origin: stackoverflow.com
for (Status s : tweets) {
System.out.println(s.getLocation()); //Returned the location of the tweet.
System.out.println(s.getUser().getLocation()); /* Returned the
User Profile Location (always constant)*/
}
代码示例来源:origin: stackoverflow.com
List<Map<String, String>> tweetList = new LinkedList<Map<String, String>>();
for (Status tweet : tweets) {
Map<String, String> tweetResult = new LinkedHashMap<String, String>();
tweetResult.put("username", tweet.getUser().getScreenName());
tweetResult.put("status", tweet.getText());
tweetResult.put("date", tweet.getCreatedAt().toString());
tweetResult.put("retweets", String.valueOf(tweet.getRetweetCount()));
tweetList.add(tweetResult);
}
String resultJson = new Gson().toJson(tweetList);
response.getWriter().write(resultJson);
代码示例来源:origin: apache/apex-malhar
@Override
protected void setStatementParameters(PreparedStatement statement, Status tuple) throws SQLException
{
statement.setLong(1, currentWindowId);
statement.setDate(2, new java.sql.Date(tuple.getCreatedAt().getTime()));
statement.setString(3, tuple.getText());
statement.setString(4, tuple.getUser().getScreenName());
statement.addBatch();
}
}
代码示例来源:origin: org.mule.modules/mule-module-twitter
@Override
public void onStatus(Status status) {
try {
callback.process(UserEvent.fromPayload(EventType.NEW_STATUS, status.getUser(), status));
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
代码示例来源:origin: tdunning/MiA
public void onStatus(Status status) {
String username = status.getUser().getScreenName();
String text = status.getText().replace('\n', ' ');
out.println(username + "\t" + text);
System.out.println(username + "\t" + text);
count++;
if(count >= maxCount) {
tweetStream.shutdown();
out.close();
}
}
代码示例来源:origin: org.apache.camel/camel-twitter
@Converter
public static String toString(Status status) throws ParseException {
return new StringBuilder()
.append(status.getCreatedAt()).append(" (").append(status.getUser().getScreenName()).append(") ")
.append(status.getText())
.toString();
}
代码示例来源:origin: stackoverflow.com
String yourstring = "your text";
List<Status> statusList = twitter.getUserTimeline(userAccount);
for (Status status : statusList) {
if(status.getText().toLowerCase().contains(yourstring)){
System.out.println(status.getUser().getName() + " : " + status.getText());
}
}
代码示例来源:origin: stackoverflow.com
Twitter twitter = TwitterFactory.getSingleton();
Query query = new Query("source:twitter4j yusukey");
QueryResult result = twitter.search(query);
for (Status status : result.getStatuses()) {
System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText());
}
代码示例来源:origin: stackoverflow.com
final Twitter twitter = new TwitterFactory().getInstance();
final List<Status> statuses = twitter.getUserTimeline(screenName);
for (Status status : statuses) {
System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
}
代码示例来源:origin: eshioji/trident-tutorial
private void extractRetweetedAccounts(Status tweet, Set<Content> contents, Status retweeted) {
if (retweeted != null) {
Content retweetedUser = newBase(tweet);
retweetedUser.setContentName(String.valueOf(retweeted.getUser().getId()));
retweetedUser.setContentType("account_retweeted");
contents.add(retweetedUser);
}
}
代码示例来源:origin: eshioji/trident-tutorial
private Content newBase(Status tweet) {
return new Content(
tweet.getId(),
tweet.getUser().getId(),
tweet.getCreatedAt().getTime()
);
}
代码示例来源:origin: org.tomitribe/chatterbox-twitter-impl
private void replyTo(final Status status, final String reply, final boolean prefix) throws TwitterException {
final String message;
if (prefix) {
message = "@" + status.getUser().getScreenName() + " " + reply;
} else {
message = reply;
}
final StatusUpdate statusUpdate = new StatusUpdate(message);
statusUpdate.setInReplyToStatusId(status.getId());
twitter.updateStatus(statusUpdate);
}
代码示例来源:origin: eshioji/trident-tutorial
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
if(extracter == null) extracter = new ContentExtracter();
String rawTweetJson = (String)tuple.get(0);
Status parsed = parse(rawTweetJson);
User user = parsed.getUser();
for (Content content : extracter.extract(parsed)) {
collector.emit(new Values(parsed, content, user));
}
}
代码示例来源:origin: nurkiewicz/rxjava-book-examples
@Test
public void sample_499() throws Exception {
Observable<Status> tweets = Observable.empty();
Observable<Long> distinctUserIds = tweets
.map(status -> status.getUser().getId())
.distinct();
}
内容来源于网络,如有侵权,请联系作者删除!