Example usage for org.springframework.social.facebook.api Facebook friendOperations

List of usage examples for org.springframework.social.facebook.api Facebook friendOperations

Introduction

In this page you can find the example usage for org.springframework.social.facebook.api Facebook friendOperations.

Prototype

FriendOperations friendOperations();

Source Link

Document

API for performing operations with a user's set of friends.

Usage

From source file:com.springsource.greenhouse.invite.FacebookInviteController.java

private List<Long> friendAccountIds(Long accountId, Facebook facebook) {
    List<Reference> friends = facebook.friendOperations().getFriends();
    if (friends.isEmpty()) {
        return Collections.emptyList();
    }//from w w w  . java2  s. co m
    Set<String> providerUserIds = new HashSet<String>(friends.size());
    for (Reference friend : friends) {
        providerUserIds.add(friend.getId());
    }
    Set<String> userIds = connectionRepository.findUserIdsConnectedTo("facebook", providerUserIds);
    List<Long> friendAccountIds = new ArrayList<Long>(userIds.size());
    for (String localUserId : userIds) {
        friendAccountIds.add(Long.valueOf(localUserId));
    }
    return friendAccountIds;
}

From source file:architecture.ee.web.community.spring.controller.FacebookController.java

@RequestMapping(value = "/friends.json", method = RequestMethod.POST)
@ResponseBody//from www.j  a  v a 2 s .c om
public List<FacebookProfile> getFriendProfiles() throws Exception {
    SocialConnect account = getSocialConnect(SecurityHelper.getUser(), Media.FACEBOOK);
    Facebook api = (Facebook) account.getConnection().getApi();
    return api.friendOperations().getFriendProfiles();
}

From source file:com.naver.template.social.HomeController.java

@RequestMapping(value = "/friends", method = RequestMethod.GET)
public String friends(Model model, HttpServletRequest request) {
    String userId = getUserIdFromServiceSecurity(model, request);
    Facebook facebook = simpleConnectionFactory.getFacebook(userId);
    log.debug("facebook{}", facebook);
    List<Reference> friends = facebook.friendOperations().getFriends();
    model.addAttribute("friends", friends);
    model.addAttribute("providerId", "facebook");
    return "friends";
}

From source file:com.naver.template.social.HomeController.java

@RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
public String home(Model model, HttpServletRequest request) {
    String userId = getUserIdFromServiceSecurity(model, request);
    Facebook facebook = null;
    try {/*  ww w.  ja  v  a 2 s . c  o m*/
        facebook = simpleConnectionFactory.getFacebook(userId);
    } catch (IllegalArgumentException e) {
        model.addAttribute("message", "Not logged in.");
        return "home";
    } catch (Exception e) {
        model.addAttribute("message", "Not connected.");
        return "home";
    }
    model.addAttribute("message", "Connected.");
    List<Reference> friends = facebook.friendOperations().getFriends();
    model.addAttribute("friends", friends);
    return "home";
}