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

Java Post类代码示例

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

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



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

示例1: getMessageByExternalId

import com.restfb.types.Post; //导入依赖的package包/类
@Override
@Cacheable(value="singleExternalMessageCache", key="#externalMessageId + '-' + #user?.id")
public Message getMessageByExternalId(String externalMessageId, User user) {
    if (!isServiceEnabled(user)) {
        return null;
    }

    FacebookClient client = helper.getFacebookClient(user);
    try {
        Post post = client.fetchObject(getFacebookId(externalMessageId), Post.class);
        return helper.postToMessage(post, user.getFacebookSettings()
                .isFetchImages(), user.getFacebookSettings().getUserId(), client);

    } catch (FacebookException ex) {
        handleException("Problem with getting a message from facebook", ex, user);
        return null;
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:19,代码来源:FacebookService.java


示例2: getMessagesOfUser

import com.restfb.types.Post; //导入依赖的package包/类
@Override
public List<Message> getMessagesOfUser(String externalId, User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }

    FacebookClient client = helper.getFacebookClient(user);

    try {
        Connection<Post> posts = client.fetchConnection(getFacebookId(externalId) + "/feed", Post.class);
        return helper.postsToMessages(posts.getData(), true, user.getFacebookSettings().getUserId(), client, false);
    } catch (FacebookException ex) {
        handleException("Problem getting friends of user " + externalId, ex, user);
        return Collections.emptyList();
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:17,代码来源:FacebookService.java


示例3: getTopRecentMessages

import com.restfb.types.Post; //导入依赖的package包/类
@Override
public List<Message> getTopRecentMessages(User user) {
    if (!isServiceEnabled(user)) {
        return Collections.emptyList();
    }

    FacebookClient client = helper.getFacebookClient(user);

    try {
        Connection<Post> con = client.fetchConnection(OWN_FEED, Post.class, Parameter.with(LIMIT_PARAM, 100));
        List<Post> posts = new ArrayList<Post>(con.getData());
        for (Iterator<Post> it = posts.iterator(); it.hasNext();) {
            Post post = it.next();
            if (!((post.getLikes() != null && post.getLikes().getCount() != null && post.getLikes().getCount().longValue() > 0)
                    || (post.getLikesCount() != null && post.getLikesCount().longValue() > 0))) {
                it.remove();
            }
        }

        List<Message> messages = helper.postsToMessages(posts, true, user.getFacebookSettings().getUserId(), client, false);
        return messages;
    } catch (FacebookException ex) {
        handleException("Problem fetching recent top own messages", ex, user);
        return Collections.emptyList();
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:27,代码来源:FacebookService.java


示例4: 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


示例5: SearchForTermUsingGeolocation

import com.restfb.types.Post; //导入依赖的package包/类
public void SearchForTermUsingGeolocation(String queryPar, int PageSize,
		double latitude, double longitude, double radius) {
	if (queryPar != null) {
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnection("search", Post.class,
				Parameter.with("q", queryPar),
				Parameter.with("type", "post"),
				Parameter.with("limit", PageSize),
				Parameter.with("place&center", latitude + "," + longitude),
				Parameter.with("distance", radius));

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData()
						.get(i)));
				OldestDate = publicSearch.getData().get(i).getCreatedTime();
			}
		}

	}
}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:22,代码来源:FacebookDriver.java


示例6: collectFeed

import com.restfb.types.Post; //导入依赖的package包/类
private Connection<Post> collectFeed(String pagename) {
	
	AccessToken accessToken = new DefaultFacebookClient(Version.VERSION_2_3).obtainAppAccessToken(ConfigurationObject.MY_APP_ID, ConfigurationObject.MY_APP_SECRET);
	FacebookClient facebookClient23 = new DefaultFacebookClient(accessToken.getAccessToken(), Version.VERSION_2_3);

	//User user = facebookClient23.fetchObject("me", User.class);
	Page page = facebookClient23.fetchObject(pagename, Page.class, Parameter.with("fields","name,id, picture, likes"));
	return  facebookClient23.fetchConnection(page.getId()+"/feed", Post.class, Parameter.with("fields", "comments, full_picture")); //message,picture, likes, from,
}
 
开发者ID:chenav,项目名称:orufeo,代码行数:10,代码来源:FacebookBoImpl.java


示例7: reshare

import com.restfb.types.Post; //导入依赖的package包/类
@Override
public void reshare(String originalMessageId, String comment, User user) {

    if (!isServiceEnabled(user)) {
        return;
    }
    FacebookClient client = helper.getFacebookClient(user);

    String fbId = getFacebookId(originalMessageId);

    try {
        Post post = client.fetchObject(fbId, Post.class);
        Message message = helper.postToMessage(post, false, null, client);
        message.setAuthor(user);
        String commentPrefix = "";
        if (StringUtils.isNotBlank(comment)) {
            commentPrefix = comment + ": ";
        }
        message.setText(commentPrefix + message.getShortText() + " (via " + post.getFrom().getName() + ")");
        share(message, user);
    } catch (FacebookException ex) {
        handleException("Failed to reshare a message on FB", ex, user);
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:25,代码来源:FacebookService.java


示例8: setNextPage

import com.restfb.types.Post; //导入依赖的package包/类
public void setNextPage() {

		results = new ArrayList();
		/*
		 * publicSearch = facebookClient.fetchConnectionPage(
		 * publicSearch.getNextPageUrl(), Post.class);
		 */
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnectionPage(
				publicSearch.getNextPageUrl(), Post.class);

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData().get(i)));
			}
		}
	}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:18,代码来源:FacebookDriver.java


示例9: setPreviousPage

import com.restfb.types.Post; //导入依赖的package包/类
public void setPreviousPage() {

		results = new ArrayList();
		/*
		 * publicSearch = facebookClient.fetchConnectionPage(
		 * publicSearch.getNextPageUrl(), Post.class);
		 */
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnectionPage(
				publicSearch.getPreviousPageUrl(), Post.class);

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData().get(i)));
			}
		}
	}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:18,代码来源:FacebookDriver.java


示例10: SearchForTerm

import com.restfb.types.Post; //导入依赖的package包/类
@Override
public void SearchForTerm(String queryPar, Integer PageSize) {
	if (queryPar != null) {
		results = new ArrayList();
		facebookClient = new DefaultFacebookClient();
		publicSearch = facebookClient.fetchConnection("search", Post.class,
				Parameter.with("q", queryPar),
				Parameter.with("type", "post"),
				Parameter.with("limit", PageSize));

		for (int i = 0; i < publicSearch.getData().size(); i++) {
			if (publicSearch.getData().get(i).getMessage() != null) {
				results.add(new FacebookPostData(publicSearch.getData()
						.get(i)));
			}
		}

	}

}
 
开发者ID:SmartSearch,项目名称:Edge-Node,代码行数:21,代码来源:FacebookDriver.java


示例11: 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


示例12: search

import com.restfb.types.Post; //导入依赖的package包/类
void search() {
  out.println("* Searching connections *");

  Connection<Post> publicSearch =
      facebookClient.fetchConnection("search", Post.class, Parameter.with("q", "watermelon"),
        Parameter.with("type", "post"));

  Connection<User> targetedSearch =
      facebookClient.fetchConnection("me/home", User.class, Parameter.with("q", "Mark"),
        Parameter.with("type", "user"));

  if (publicSearch.getData().size() > 0)
    out.println("Public search: " + publicSearch.getData().get(0).getMessage());

  out.println("Posts on my wall by friends named Mark: " + targetedSearch.getData().size());
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:17,代码来源:GraphReaderExample.java


示例13: testMultipleFieldsWithSameName

import com.restfb.types.Post; //导入依赖的package包/类
@Test
public void testMultipleFieldsWithSameName() {
  JsonMapper jsonMapper = createJsonMapper();

  User user1 = jsonMapper.toJavaObject(jsonFromClasspath("user-with-hometown-v1"), User.class);
  assertTrue("Beograd".equals(user1.getHometownName()));
  assertTrue(user1.getHometown() == null);

  User user2 = jsonMapper.toJavaObject(jsonFromClasspath("user-with-hometown-v2"), User.class);
  assertTrue("Belgrade, Serbia".equals(user2.getHometown().getName()));
  assertTrue("Belgrade, Serbia".equals(user2.getHometownName()));

  Post post1 = jsonMapper.toJavaObject(jsonFromClasspath("post-with-likes-v1"), Post.class);
  assertTrue(post1.getLikesCount() == 4);
  assertTrue(post1.getLikes() == null);

  Post post2 = jsonMapper.toJavaObject(jsonFromClasspath("post-with-likes-v2"), Post.class);
  assertTrue(post2.getLikes().getCount() == 49);
  assertTrue(post2.getLikesCount() == 49);
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:21,代码来源:JsonMapperToJavaTest.java


示例14: fetchConnections

import com.restfb.types.Post; //导入依赖的package包/类
void fetchConnections() {
  out.println("* Fetching connections *");

  Connection<User> myFriends = facebookClient25.fetchConnection("me/friends", User.class);
  Connection<Post> myFeed = facebookClient25.fetchConnection("me/feed", Post.class);

  out.println("Count of my friends: " + myFriends.getData().size());

  if (!myFeed.getData().isEmpty())
    out.println("First item in my feed: " + myFeed.getData().get(0).getMessage());
}
 
开发者ID:restfb,项目名称:restfb-examples,代码行数:12,代码来源:GraphReaderExample.java


示例15: paging

import com.restfb.types.Post; //导入依赖的package包/类
void paging() {
  out.println("* Paging support *");

  Connection<User> myFriends = facebookClient25.fetchConnection("me/friends", User.class);
  Connection<Post> myFeed = facebookClient25.fetchConnection("me/feed", Post.class, Parameter.with("limit", 100));

  out.println("Count of my friends: " + myFriends.getData().size());

  if (!myFeed.getData().isEmpty())
    out.println("First item in my feed: " + myFeed.getData().get(0));

  for (List<Post> myFeedConnectionPage : myFeed)
    for (Post post : myFeedConnectionPage)
      out.println("Post from my feed: " + post);
}
 
开发者ID:restfb,项目名称:restfb-examples,代码行数:16,代码来源:GraphReaderExample.java


示例16: getMessages

import com.restfb.types.Post; //导入依赖的package包/类
private Future<List<Message>> getMessages(User user, Message lastMessage, String connection) {
    if (!isServiceEnabled(user)) {
        return SocialUtils.emptyFutureList();
    }
    FacebookClient client = helper.getFacebookClient(user);

    try {
        Parameter[] params;
        if (lastMessage != null) {
            params = new Parameter[2];
            params[1] = Parameter.with("until", lastMessage.getDateTime()
                    .getMillis() / DateTimeConstants.MILLIS_PER_SECOND - 1);
        } else {
            params = new Parameter[1];
        }
        params[0] = Parameter.with(LIMIT_PARAM, messagesPerFetch);
        Connection<Post> con = client.fetchConnection(connection, Post.class, params);
        List<Post> result = con.getData();

        if (result.isEmpty()) {
            return SocialUtils.emptyFutureList();
        }

        List<Message> messages = helper.postsToMessages(result,
                user.getFacebookSettings().isFetchImages(),
                user.getFacebookSettings().getUserId(), client);

        return SocialUtils.wrapMessageList(messages);
    } catch (FacebookException ex) {
        handleException("Problem with getting messages from facebook", ex, user);
        return SocialUtils.emptyFutureList();
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:34,代码来源:FacebookService.java


示例17: importMessages

import com.restfb.types.Post; //导入依赖的package包/类
@Override
public void importMessages(User user) {
    if (!isServiceEnabled(user) || !user.getFacebookSettings().isImportMessages()) {
        return;
    }
    try {
        FacebookClient client = helper.getBackgroundFacebookClient(user);

        Parameter[] params = new Parameter[2];
        params[0] = Parameter.with(LIMIT_PARAM, 100);
        params[1] = Parameter.with("since", user.getFacebookSettings().getLastImportedMessageTime() / DateTimeConstants.MILLIS_PER_SECOND + 1);

        Connection<Post> con = client.fetchConnection(OWN_FEED, Post.class, params);
        List<Post> posts = con.getData();

        if (posts.size() == 0) {
            return;
        }

        List<Message> messages = helper.postsToMessages(posts,
                user.getFacebookSettings().isFetchImages(),
                user.getFacebookSettings().getUserId(), null);

        helper.importExternalMessages(user, messages);

    } catch (FacebookException e) {
        handleException("Problem importing facebook messages for user " + user , e, user);
    }

}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:31,代码来源:FacebookService.java


示例18: createFeedItem

import com.restfb.types.Post; //导入依赖的package包/类
/**
 * Creates a FeedItem from a Post.
 * @param post The Post from which the data is to be extracted
 * @param feedType The feed item type
 * @return The created FeedItem object
 */
private FeedItem createFeedItem(Post post, FeedItem.FeedType feedType) {
    FeedItem feedItem = new FeedItem();
    feedItem.setContentID(extractContentID(post));
    feedItem.setFeedType(feedType);
    feedItem.setFeedItemID(post.getId());
    feedItem.setTime(post.getCreatedTime());
    feedItem.setType(post.getType());
    feedItem.setUserID(post.getFrom().getId());
    return feedItem;
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:17,代码来源:MonitorRunner.java


示例19: extractContentID

import com.restfb.types.Post; //导入依赖的package包/类
/**
 * Extracts the content id from a given Post object.
 *
 * @param post The post object from which the id is to be extracted
 * @return Returns the content id in a given Post object.
 */
private long extractContentID(Post post) {
    long contentID = -1;
    if(post.getLink() != null) {
        contentID = extractContentID(post.getLink());
    }
    if(contentID == -1 && post.getDescription() != null) {
        contentID = extractContentID(post.getDescription());
    }
    return contentID;
}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:17,代码来源:MonitorRunner.java


示例20: fetchConnections

import com.restfb.types.Post; //导入依赖的package包/类
void fetchConnections() {
  out.println("* Fetching connections *");

  Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class);
  Connection<Post> myFeed = facebookClient.fetchConnection("me/feed", Post.class);

  out.println("Count of my friends: " + myFriends.getData().size());

  if (myFeed.getData().size() > 0)
    out.println("First item in my feed: " + myFeed.getData().get(0).getMessage());
}
 
开发者ID:oleke,项目名称:Gender-Mining,代码行数:12,代码来源:GraphReaderExample.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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