当前位置: 首页>>代码示例>>Java>>正文


Java Post.getComments方法代码示例

本文整理汇总了Java中com.restfb.types.Post.getComments方法的典型用法代码示例。如果您正苦于以下问题:Java Post.getComments方法的具体用法?Java Post.getComments怎么用?Java Post.getComments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.restfb.types.Post的用法示例。


在下文中一共展示了Post.getComments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateReputation

import com.restfb.types.Post; //导入方法依赖的package包/类
private int calculateReputation(Connection<Post> con) {
    int reputation = 0;
    for (Post post : con.getData()) {
        // likes weigh less than retweets and welshare likes, because they don't mean "share"
        if (post.getLikesCount() != null) {
            reputation += post.getLikesCount().intValue() * (Constants.LIKE_SCORE - 2);
        } else if (post.getLikes() != null && post.getLikes().getCount() != null) {
            reputation += post.getLikes().getCount().intValue() * (Constants.LIKE_SCORE - 2);
        }

        if (post.getComments() != null && post.getComments().getCount() != null) {
            int commentCount = post.getComments().getCount().intValue();
            commentCount = Math.min(commentCount, 7); //limit to 7 comments; not taking long discussion into account
            reputation +=  commentCount * Constants.REPLY_SCORE;
        }
    }
    return reputation;
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:19,代码来源:FacebookService.java

示例2: FacebookPostData

import com.restfb.types.Post; //导入方法依赖的package包/类
public FacebookPostData(Post FBpost) {
	UserName = FBpost.getFrom().getName();
	UserID= FBpost.getFrom().getId();
	this.Message = FBpost.getMessage();
	this.CreationDate = FBpost.getCreatedTime();
	this.Likes = FBpost.getLikesCount();
	this.Source="Facebook";
	if (FBpost.getPlace() != null) {
		this.LocationName = FBpost.getPlace().getLocation().getCity();
		this.GeoLatitude = FBpost.getPlace().getLocation().getLatitude();
		this.GeoLongitude = FBpost.getPlace().getLocation().getLatitude();
	}
	if (FBpost.getComments() != null) {
		for (int i = 0; i < FBpost.getComments().getCount(); i++)
			this.Comments.add(new FacebookPostData(FBpost.getComments()
					.getData().get(i)));
	}
}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:19,代码来源:FacebookPostData.java

示例3: searchPage

import com.restfb.types.Post; //导入方法依赖的package包/类
@Override
public void searchPage(String pagename) {

	Connection<Post> myFeed = collectFeed(pagename);

	for (List<Post> myFeedPage : myFeed) {  //paging made in facebook api

		// Iterate over the list of contained data 
		// to access the individual object
		for (Post post : myFeedPage) {

			if (null!=post.getComments() && post.getComments().getData()!=null) {

				for ( Comment comment : post.getComments().getData()) {

					try {
						NplAnalyzer analyzer = NplAnalyzer.getInstance();

						Sentiment feeling = analyzer.analyze(comment.getMessage());

						if (feeling.getScore() < 0 && feeling.getMagnitude()>1) {
							System.out.println("**********************************");
							System.out.println("Date :"+comment.getCreatedTime());
							System.out.println("User :"+comment.getFrom().getName());
							System.out.println("UserId :"+comment.getFrom().getId());
							System.out.println("Message :"+comment.getMessage());
							System.out.println("Sentiment: score="+ feeling.getScore()+", magnitude="+ feeling.getMagnitude());
							
						}
					} catch (Exception e) {
						System.out.println("ERROR in analysis: "+e.getMessage());
					}

				}
			}

		}
	}


}
 
开发者ID:chenav,项目名称:orufeo,代码行数:42,代码来源:FacebookBoImpl.java

示例4: poll

import com.restfb.types.Post; //导入方法依赖的package包/类
public List<FacebookPerception> poll() {
	List<FacebookPerception> perceptions = new ArrayList<>();
	final String meFeed = "/me/feed";
	log.info("Fetching {} ...", meFeed);
	Connection<Post> connection = fb.fetchConnection(meFeed, Post.class);
	log.info("{} posts: {}", connection.getData().size(), connection.getData());
	for (Post post : connection.getData()) {
		log.info("{} {} from {} {}: {}", 
				post.getType(), post.getId(), post.getFrom().getId(), post.getFrom().getName(), 
				post.getMessage());
		if ( post.getMessage() != null && "status".equals(post.getType()) && 
				sysConfig.getFacebookProfileId() != Long.valueOf(post.getFrom().getId()) &&
				!StringUtils.equals(sysConfig.getFacebookProfileName(), post.getFrom().getName()) ) {
			log.info("Fetching {} {} from {} {}...", post.getType(), post.getId(), post.getFrom().getId(), post.getFrom().getName());
			StatusMessage status = fb.fetchObject(post.getId(), StatusMessage.class);
			log.info("Status {} (comments: {}), {} likes, {} shares: {}", 
					post.getId(), post.getComments(), post.getLikesCount(), post.getSharesCount(), status);
			if (post.getComments() != null) {
				ImmutableList<Comment> myReplies = FluentIterable.from(post.getComments().getData()).filter(new Predicate<Comment>() {
					@Override
					public boolean apply(Comment input) {
						return sysConfig.getFacebookProfileId() == Long.valueOf(input.getFrom().getId()) ||
								StringUtils.equals(sysConfig.getFacebookProfileName(), input.getFrom().getName());
					};
				}).toList();
				if (!myReplies.isEmpty()) {
					log.debug("Post {} has my replies: {}", post.getId(), myReplies);
					// check if last comment is from other, mentions me, and hasn't been replied?
					Comment lastComment = Iterables.getLast(post.getComments().getData());
					if (sysConfig.getFacebookProfileId() != Long.valueOf(lastComment.getFrom().getId()) &&
							StringUtils.containsIgnoreCase(lastComment.getMessage(), sysConfig.getFacebookProfileName()) &&
							!StringUtils.equals(sysConfig.getFacebookProfileName(), lastComment.getFrom().getName())) {
						log.debug("Comment {} from {} {} has not been replied: {}", 
								lastComment.getId(), lastComment.getFrom().getId(), lastComment.getFrom().getName(), lastComment.getMessage());
						perceptions.add( new FacebookPerception(post, 
								Long.valueOf(lastComment.getFrom().getId()), lastComment.getFrom().getName(), lastComment.getMessage(), post.getId()) );
					}
				} else {
					log.debug("Post {} not replied yet", post.getId());
					perceptions.add( new FacebookPerception(post, Long.valueOf(post.getFrom().getId()), post.getFrom().getName(), post.getMessage(), post.getId()) );
				}
			} else {
				log.debug("Post {} not replied yet", post.getId());
				perceptions.add( new FacebookPerception(post, Long.valueOf(post.getFrom().getId()), post.getFrom().getName(), post.getMessage(), post.getId()) );
			}
		}
	}
	if (!perceptions.isEmpty()) {
		log.info("{} perceptions: {}", perceptions.size(), perceptions);
	}
	return perceptions;
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:53,代码来源:FacebookChannel.java


注:本文中的com.restfb.types.Post.getComments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。