• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Comment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Comment类属于com.restfb.types包,在下文中一共展示了Comment类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: respond

import com.restfb.types.Comment; //导入依赖的package包/类
public List<FacebookActionResult> respond(
		List<FacebookAction> actions) {
	List<FacebookActionResult> results = new ArrayList<>();
	for (FacebookAction action : actions) {
		final String destPath = "/" + action.destId + "/comments";
		log.info("Commenting {}... {}", destPath, action.replyMessage);
		Comment commented = fb.publish(destPath, Comment.class, Parameter.with("message", action.replyMessage));
		log.info("Commented {} for {} {} > {}", action.destId, action.partnerId, action.partnerName, commented);
		results.add(new FacebookActionResult(action.originalPost, action.destId, action.partnerId, action.partnerName,
				commented));
	}
	if (!results.isEmpty()) {
		log.info("{} results: {}", results.size(), results);
	}
	return results;
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:17,代码来源:FacebookChannel.java


示例2: processComments

import com.restfb.types.Comment; //导入依赖的package包/类
public void processComments(String objectId) {
    // Comments will belong to a post so in addition to having an edge to the author
    // of the comment, there will be an edge to the parent post as well. Finally, the
    // comment may have likes which are handled in the processLikes() method.
    Connection<Comment> commentPages = client.fetchConnection(objectId + "/comments", Comment.class);

    for (List<Comment> comments : commentPages) {
        for (Comment comment : comments) {
            String fromUserId = comment.getFrom().getId();
            Process userProcess = getUserVertex(fromUserId);

            if(userProcess == null){
                continue;
            }

            Artifact commentArtifact = new Artifact();
            commentArtifact.addAnnotation("objectId", comment.getId());
            commentArtifact.addAnnotation("author", userProcess.getAnnotation("name"));
            commentArtifact.addAnnotation("message", comment.getMessage());
            commentArtifact.addAnnotation("time", comment.getCreatedTime().toString());
            commentArtifact.addAnnotation("fbType", "comment");
            objects.put(comment.getId(), commentArtifact);
            putVertex(commentArtifact);

            WasGeneratedBy wgb = new WasGeneratedBy(commentArtifact, userProcess);
            wgb.addAnnotation("fbType", "comment");
            putEdge(wgb);

            WasDerivedFrom wdf = new WasDerivedFrom(commentArtifact, (Artifact) objects.get(objectId));
            wdf.addAnnotation("fbType", "commentParent");
            putEdge(wdf);

            processLikes(comment.getId());
        }
    }
}
 
开发者ID:ashish-gehani,项目名称:SPADE,代码行数:37,代码来源:Facebook.java


示例3: photoInfo

import com.restfb.types.Comment; //导入依赖的package包/类
public static HashMap<SerializerKey, Object> photoInfo(Photo photo, File photoXml, FacebookClient fbc)
{
	HashMap<SerializerKey, Object> infos = new HashMap<>();
	if (photo == null)
		return infos;
	infos.put(PhotoInfoKey.FILE, "./photo.jpg");
	infos.put(PhotoInfoKey.BACK_DATE, (photo.getBackdatedTime() == null) ? null : photo.getBackdatedTime());
	infos.put(PhotoInfoKey.COMMENT_DIR, "./comments");
	infos.put(PhotoInfoKey.COMMENT_INFO_FILENAME, "./commentinfo.xml");
	infos.put(PhotoInfoKey.LAST_UPDATE, photo.getUpdatedTime());
	infos.put(PhotoInfoKey.ORIGINAL_LINK, photo.getLink());
	infos.put(PhotoInfoKey.LIKES_FROM_PEOPLE, photo.getLikes());
	infos.put(PhotoInfoKey.LIKES, photo.getLikes().size());
	infos.put(PhotoInfoKey.LOCATION, (photo.getPlace() != null) ? photo.getPlace().getLocation() : null);
	infos.put(PhotoInfoKey.PLACE, photo.getPlace());
	infos.put(PhotoInfoKey.PUBLISH_DATE, photo.getCreatedTime());
	infos.put(PhotoInfoKey.ID, photo.getId());
	infos.put(PhotoInfoKey.FROM, photo.getFrom());
	infos.put(PhotoInfoKey.TAGS, photo.getTags());
	infos.put(PhotoInfoKey.ICON, photo.getIcon());
	infos.put(PhotoInfoKey.HEIGHT, photo.getHeight());
	infos.put(PhotoInfoKey.IMAGES, photo.getImages());
	infos.put(PhotoInfoKey.NAME, photo.getName());
	infos.put(PhotoInfoKey.PICTURE, photo.getPicture());
	infos.put(PhotoInfoKey.WIDTH, photo.getWidth());
	writeInfos(infos, photoXml, "Represents a photo");
	File commentsDir = FileUtils.resolveRelativePath(photoXml.getParentFile(), infos.get(PhotoInfoKey.COMMENT_DIR).toString());
	for (Comment cmt : photo.getComments())
	{

		Comment comment = fbc.fetchObject(cmt.getId(), Comment.class, MasterParameter.getParameterByClass(Comment.class));
		File commentDir = new File("" + commentsDir + "/" + comment.getId());
		commentDir.mkdirs();
		File commentXml = FileUtils.resolveRelativePath(commentDir, infos.get(PhotoInfoKey.COMMENT_INFO_FILENAME).toString());
		commentInfo(comment, commentXml, fbc);
	}
	downloadPhoto(photo, FileUtils.resolveRelativePath(photoXml.getParentFile(), infos.get(PhotoInfoKey.FILE).toString()));
	return infos;
}
 
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:40,代码来源:Serializer.java


示例4: commentInfo

import com.restfb.types.Comment; //导入依赖的package包/类
public static void commentInfo(Comment comment, File commentXml, FacebookClient fbc)
{
	if (!commentXml.getParentFile().exists())
		commentXml.getParentFile().mkdirs();
	HashMap<SerializerKey, Object> infos = new HashMap<>();
	File photoJpg = null;
	if (comment.getAttachment() != null)
	{
		Comment.Image cimg = comment.getAttachment().getMedia().getImage();
		Photo photo = new Photo();
		photo.setId("attachment");
		Photo.Image img = new Image();
		img.setSource(cimg.getSrc());
		img.setHeight(cimg.getHeight());
		img.setWidth(cimg.getWidth());
		photo.addImage(img);
		photoJpg = new File("" + commentXml.getParentFile() + "/attachment/photoinfo.xml");
		photoInfo(photo, photoJpg, fbc);
	}
	infos.put(CommentKey.ATTACHMENT, FileUtils.getWayTo(commentXml, photoJpg));
	infos.put(CommentKey.CAN_REMOVE, comment.getCanRemove());
	infos.put(CommentKey.CREATED, comment.getCreatedTime());
	infos.put(CommentKey.FROM, comment.getFrom());
	infos.put(CommentKey.HIDDEN, comment.getIsHidden());
	infos.put(CommentKey.ID, comment.getId());
	infos.put(CommentKey.LIKE_COUNT, comment.getLikeCount());
	infos.put(CommentKey.MESSAGE, comment.getMessage());
	infos.put(CommentKey.REPLIES_COUNT, comment.getCommentCount());
	infos.put(CommentKey.METADATA, comment.getMetadata());
	writeInfos(infos, commentXml, "Represents a comment");
	if (comment.getComments() != null)
		for (Comment c : comment.getComments().getData())
			commentInfo(c, new File("" + commentXml + "/" + c.getId()), fbc);
}
 
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:35,代码来源:Serializer.java


示例5: FacebookActionResult

import com.restfb.types.Comment; //导入依赖的package包/类
public FacebookActionResult(Post originalPost, String destId,
		long partnerId, String partnerName, Comment commented) {
	this.originalPost = originalPost;
	this.destId = destId;
	this.partnerId = partnerId;
	this.partnerName = partnerName;
	this.commented = commented;
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:9,代码来源:FacebookChannel.java


示例6: searchPage

import com.restfb.types.Comment; //导入依赖的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


示例7: retrieveAccountFeed

import com.restfb.types.Comment; //导入依赖的package包/类
@Override
public Response retrieveAccountFeed(AccountFeed feed, Integer maxRequests) {
	
	Response response = new Response();
	List<Post> items = new ArrayList<Post>();

	Integer totalRequests = 0;
	
	Date lastItemDate = feed.getSinceDate();
	String label = feed.getLabel();
	
	boolean isFinished = false;
	
	String userName = feed.getUsername();
	if(userName == null) {
		logger.error("#Facebook : No source feed");
		return response;
	}
	String userFeed = userName+"/feed";
	
	Connection<com.restfb.types.Post> connection;
	User page;
	try {
		connection = facebookClient.fetchConnection(userFeed , com.restfb.types.Post.class);
		page = facebookClient.fetchObject(userName, User.class);
	}
	catch(Exception e) {
		return response;
	}
	
	FacebookAccount facebookUser = new FacebookAccount(page);
	for(List<com.restfb.types.Post> connectionPage : connection) {	
		totalRequests++;
		for(com.restfb.types.Post post : connectionPage) {	
			
			Date publicationDate = post.getCreatedTime();
			
			if(publicationDate.after(lastItemDate) && post!=null && post.getId() != null) {
				FacebookPost facebookPost = new FacebookPost(post, facebookUser);
				//facebookUpdate.setList(label);
				
				items.add(facebookPost);
				
				com.restfb.types.Post.Comments comments = post.getComments();
			    if(comments != null) {
			    	for(Comment comment : comments.getData()) {
		    			FacebookPost facebookComment = new FacebookPost(comment, post, null);
		    			//facebookComment.setList(label);
		    			
		    			items.add(facebookComment);
		    		} 
			    }
			 }
			
			if(publicationDate.before(lastItemDate) || totalRequests>maxRequests){
				isFinished = true;
				break;
			}
		
		}
		if(isFinished)
			break;
		
	}

	logger.info("Facebook: " + items.size() + " posts from " + userFeed + " [ " + lastItemDate + " - " + new Date(System.currentTimeMillis()) + " ]");
	
	response.setPosts(items);
	response.setRequests(totalRequests);
	return response;
}
 
开发者ID:MKLab-ITI,项目名称:simmo-stream-manager,代码行数:72,代码来源:FacebookRetriever.java


示例8: postInfo

import com.restfb.types.Comment; //导入依赖的package包/类
public static HashMap<SerializerKey, Object> postInfo(Post post, File postXml, FacebookClient fbc)
{
	HashMap<SerializerKey, Object> infos = new HashMap<>();
	if (post == null || postXml == null)
		return infos;
	infos.put(PostInfoKey.ACTION, post.getActions());
	infos.put(PostInfoKey.ADMIN, post.getAdminCreator());
	infos.put(PostInfoKey.APPLICATION, post.getApplication());
	infos.put(PostInfoKey.ATTRIBUTION, post.getAttribution());
	infos.put(PostInfoKey.CAPTION, post.getCaption());
	infos.put(PostInfoKey.COMMENTS, post.getComments());
	infos.put(PostInfoKey.COMMENTS_COUNT, post.getCommentsCount());
	infos.put(PostInfoKey.CREATED_TIME, post.getCreatedTime());
	infos.put(PostInfoKey.DESCRIPTION, post.getDescription());
	infos.put(PostInfoKey.FROM, post.getFrom());
	infos.put(PostInfoKey.ICON, post.getIcon());
	infos.put(PostInfoKey.ID, post.getId());
	infos.put(PostInfoKey.LAST_UPDATE, post.getUpdatedTime());
	infos.put(PostInfoKey.LIKES, post.getLikes());
	infos.put(PostInfoKey.LIKES_COUNT, post.getLikesCount());
	infos.put(PostInfoKey.LINK, post.getLink());
	infos.put(PostInfoKey.MESSAGE, post.getMessage());
	infos.put(PostInfoKey.MESSAGE_TAGS, post.getMessageTags());
	infos.put(PostInfoKey.OBJECT_ID, post.getObjectId());
	File photoXml = null;
	if (post.getObjectId() != null)
	{
		Photo photo = fbc.fetchObject(post.getObjectId(), Photo.class, MasterParameter.getParameterByClass(Photo.class));
		photoXml = new File("" + postXml.getParentFile() + "/object/photoinfo.xml");
		photoInfo(photo, photoXml, fbc);
	}
	// In my case, it does not send any comments, but i also get no comments
	// from the Graph API Explorer
	Connection<Comment> commentConnection = fbc.fetchConnection(post.getId() + "/comments", Comment.class, MasterParameter.getByClass(Comment.class).getParameter());
	for (List<Comment> comments : commentConnection)
	{
		for (Comment comment : comments)
		{
			commentInfo(comment, new File("" + postXml.getParentFile() + "/comments/" + comment.getId() + "/commentinfo.xml"), fbc);
		}
	}
	infos.put(PostInfoKey.PICTURE, FileUtils.getWayTo(postXml, photoXml));
	infos.put(PostInfoKey.PLACE, post.getPlace());
	infos.put(PostInfoKey.PRIVACY, post.getPrivacy());
	infos.put(PostInfoKey.PROPERTIES, post.getProperties());
	infos.put(PostInfoKey.SHARES, post.getShares());
	infos.put(PostInfoKey.SHARES_COUNT, post.getSharesCount());
	infos.put(PostInfoKey.SOURCE, post.getSource());
	infos.put(PostInfoKey.STATUS_TYPE, post.getStatusType());
	writeInfos(infos, postXml, "Represents a post");
	return infos;
}
 
开发者ID:RStoeckl,项目名称:themis-fb,代码行数:53,代码来源:Serializer.java


示例9: accumulateUserActivity

import com.restfb.types.Comment; //导入依赖的package包/类
private void accumulateUserActivity(HashMap<String, Integer> likedFriendsPosts,
        HashMap<String, Integer> commentedFriendsPosts,
        HashMap<String, Integer> sharedFriendsPosts,
        HashMap<String, Integer> commonActivityUsers,
        HashMap<String, Integer> postsPerUser,
        ExtendedPost post) {
    HashSet<String> activeUsers = new HashSet<String>();
    boolean isActionedByUser = false;
    if (!postsPerUser.containsKey(post.getFrom().getId())) {
        postsPerUser.put(post.getFrom().getId(), 0);
    }
    postsPerUser.put(post.getFrom().getId(), postsPerUser.get(post.getFrom().getId()) + 1);
    if (post.getLikes() != null) {
        for (NamedFacebookType likedUser : post.getLikes().getData()) {
            activeUsers.add(likedUser.getId());
            if (likedUser.getId().equals(userId)) {
                isActionedByUser = true;
                if (!likedFriendsPosts.containsKey(post.getFrom().getId())) {
                    likedFriendsPosts.put(post.getFrom().getId(), 0);
                }
                likedFriendsPosts.put(post.getFrom().getId(), likedFriendsPosts.get(post.getFrom().getId()) + 1);
            }
        }
    }
    if (post.getComments() != null) {
        for (Comment comment : post.getComments().getData()) {
            activeUsers.add(comment.getFrom().getId());
            if (comment.getFrom().getId().equals(userId) & !isActionedByUser) {
                isActionedByUser = true;
                if (!commentedFriendsPosts.containsKey(post.getFrom().getId())) {
                    commentedFriendsPosts.put(post.getFrom().getId(), 0);
                }
                commentedFriendsPosts.put(post.getFrom().getId(), commentedFriendsPosts.get(post.getFrom().getId()) + 1);
            }
        }
    }
    if (isActionedByUser) {
        for (String id : activeUsers) {
            if (!commonActivityUsers.containsKey(id)) {
                commonActivityUsers.put(id, 0);
            }
            commonActivityUsers.put(id, commonActivityUsers.get(id) + 1);
        }
    }
}
 
开发者ID:milenchechev,项目名称:RecommendedStream,代码行数:46,代码来源:UserDataCollector.java


示例10: FacebookPostData

import com.restfb.types.Comment; //导入依赖的package包/类
FacebookPostData(Comment FBpost) {
	this.UserName = FBpost.getFrom().getId();
	this.Message = FBpost.getMessage();
	this.CreationDate = FBpost.getCreatedTime();
	this.Likes = FBpost.getLikes();
}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:7,代码来源:FacebookPostData.java


示例11: poll

import com.restfb.types.Comment; //导入依赖的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.Comment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Interval类代码示例发布时间:2022-05-22
下一篇:
Java VerisignCzagExtension类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap