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


Java Post类代码示例

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


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


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