Examples of FacebookProfile


Examples of org.encuestame.social.api.support.FacebookProfile

         * sometimes the username is not configured on facebook profile (eg. new profiles) in this cases
         * our username social account is required, we use unique facebook id, this is completely valid to build
         * facebook picture.
         */
        final String username = String.valueOf(profileMap.get("username") == null ? profileMap.get("id") : profileMap.get("username"));
        return new FacebookProfile(id, name, firstName, lastName, email, username);
    }
View Full Code Here

Examples of org.encuestame.social.api.support.FacebookProfile

     * (non-Javadoc)
     * @see org.encuestame.core.social.SocialAPIOperations#getProfile()
     */
    @Override
    public SocialUserProfile getProfile() {
        final FacebookProfile facebookProfile = this.getUserProfile();
        Log.debug("Facebook PRofile "+facebookProfile.toString());
        final SocialUserProfile profile = new SocialUserProfile();
        profile.setEmail(facebookProfile.getEmail());
        profile.setFirstName(facebookProfile.getFirstName());
        profile.setLastName(facebookProfile.getLastName());
        profile.setId(String.valueOf(facebookProfile.getId()));
        profile.setProfileImageUrl(PICTURE_PROFILE_URL.replace("{objectId}", facebookProfile.getUsername()));
        profile.setName(facebookProfile.getName());
        profile.setUsername(facebookProfile.getUsername());
        return profile;
    }
View Full Code Here

Examples of org.pac4j.oauth.profile.facebook.FacebookProfile

        kryo.register(FacebookPhoto.class);
    }
   
    @Override
    protected void verifyProfile(final UserProfile userProfile) {
        final FacebookProfile profile = (FacebookProfile) userProfile;
        logger.debug("userProfile : {}", profile);
        assertEquals("100003571536393", profile.getId());
        assertEquals(FacebookProfile.class.getSimpleName() + UserProfile.SEPARATOR + "100003571536393",
                     profile.getTypedId());
        assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), FacebookProfile.class));
        assertTrue(StringUtils.isNotBlank(profile.getAccessToken()));
        assertCommonProfile(userProfile, null, "Jerome", "Testscribeup", "Jerome Testscribeup", null,
                            Gender.MALE, Locale.FRANCE, "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-",
                            "https://www.facebook.com/jerome.testscribeup", "New York, New York");
        assertNull(profile.getMiddleName());
        final List<FacebookObject> languages = profile.getLanguages();
        assertTrue(languages.get(0).getName().startsWith("Fr"));
        assertTrue(StringUtils.isNotBlank(profile.getThirdPartyId()));
        assertEquals(2, profile.getTimezone().intValue());
        assertTrue(profile.getVerified());
        assertEquals("A propos de moi", profile.getBio());
        assertEquals("03/10/1979", profile.getBirthday().toString());
        final List<FacebookEducation> educations = profile.getEducation();
        FacebookEducation education = educations.get(0);
        assertEquals("lycée mixte", education.getSchool().getName());
        assertEquals("2000", education.getYear().getName());
        assertEquals("High School", education.getType());
        education = educations.get(1);
        assertEquals("Ingénieur", education.getDegree().getName());
        assertNull(profile.getEmail());
        assertEquals("San Francisco, California", (profile.getHometown()).getName());
        assertEquals("female", (profile.getInterestedIn()).get(0));
        assertEquals("New York, New York", (profile.getLocationObject()).getName());
        assertEquals("Sans Opinion (desc)", profile.getPolitical());
        final List<FacebookObject> favoriteAthletes = profile.getFavoriteAthletes();
        assertEquals("Surfing", favoriteAthletes.get(0).getName());
        final List<FacebookObject> favoriteTeams = profile.getFavoriteTeams();
        assertEquals("Handball Féminin de France", favoriteTeams.get(0).getName());
        assertEquals("citation", profile.getQuotes());
        assertEquals(FacebookRelationshipStatus.MARRIED, profile.getRelationshipStatus());
        assertEquals("Athéisme (desc)", profile.getReligion());
        assertNull(profile.getSignificantOther());
        assertEquals("web site", profile.getWebsite());
        final List<FacebookWork> works = profile.getWork();
        final FacebookWork work = works.get(0);
        assertEquals("Employeur", work.getEmployer().getName());
        assertEquals("Paris, France", work.getLocation().getName());
        assertEquals("Architecte Web", work.getPosition().getName());
        assertEquals("Description", work.getDescription());
        assertTrue(work.getStartDate() instanceof Date);
        assertNull(work.getEndDate());
        final List<FacebookObject> friends = profile.getFriends();
        assertEquals(1, friends.size());
        final FacebookObject friend = friends.get(0);
        assertEquals("Jérôme Leleu", friend.getName());
        assertEquals("100002406067613", friend.getId());
        final List<FacebookInfo> movies = profile.getMovies();
        assertEquals(1, movies.size());
        final FacebookInfo movie = movies.get(0);
        assertEquals("Jean-Claude Van Damme", movie.getName());
        assertEquals("21497365045", movie.getId());
        assertEquals("Actor/director", movie.getCategory());
        assertEquals(1330030350000L, movie.getCreatedTime().getTime());
        final List<FacebookInfo> musics = profile.getMusic();
        assertEquals(1, musics.size());
        final FacebookInfo music = musics.get(0);
        assertEquals("Hard rock", music.getName());
        assertEquals("112175695466436", music.getId());
        assertEquals("Movie genre", music.getCategory());
        assertEquals(1330030350000L, music.getCreatedTime().getTime());
        final List<FacebookInfo> books = profile.getBooks();
        assertEquals(1, books.size());
        final FacebookInfo book = books.get(0);
        assertEquals("Science fiction", book.getName());
        assertEquals("108157509212483", book.getId());
        assertEquals("Tv genre", book.getCategory());
        assertEquals(1330030350000L, book.getCreatedTime().getTime());
        final List<FacebookInfo> likes = profile.getLikes();
        assertEquals(8, likes.size());
        final FacebookInfo like = likes.get(0);
        assertEquals("Boxing", like.getName());
        assertEquals("105648929470083", like.getId());
        assertEquals("Sport", like.getCategory());
        assertEquals(1360152791000L, like.getCreatedTime().getTime());
        final List<FacebookPhoto> albums = profile.getAlbums();
        assertEquals(3, albums.size());
        final FacebookPhoto album = albums.get(1);
        assertEquals("168023009993416", album.getId());
        final FacebookObject from = album.getFrom();
        assertEquals("100003571536393", from.getId());
        assertEquals("Jerome Testscribeup", from.getName());
        assertEquals("Profile Pictures", album.getName());
        assertEquals("https://www.facebook.com/album.php?fbid=168023009993416&id=100003571536393&aid=34144",
                     album.getLink());
        assertEquals("168023156660068", album.getCoverPhoto());
        assertEquals("everyone", album.getPrivacy());
        assertEquals(1, album.getCount().intValue());
        assertEquals("profile", album.getType());
        assertEquals(1336472634000L, album.getCreatedTime().getTime());
        assertEquals(1336472660000L, album.getUpdatedTime().getTime());
        assertFalse(album.getCanUpload());
        final List<FacebookEvent> events = profile.getEvents();
        assertEquals(1, events.size());
        final FacebookEvent event = events.get(0);
        assertEquals("Couronnement", event.getName());
        assertEquals("301212149963131", event.getId());
        assertTrue(event.getLocation().indexOf("Paris") >= 0);
        assertEquals("attending", event.getRsvpStatus());
        assertNotNull(event.getStartTime());
        assertNotNull(event.getEndTime());
        final List<FacebookGroup> groups = profile.getGroups();
        final FacebookGroup group = groups.get(0);
        assertNull(group.getVersion());
        assertEquals("Dev ScribeUP", group.getName());
        assertEquals("167694120024728", group.getId());
        assertTrue(group.getAdministrator());
        assertEquals(1, group.getBookmarkOrder().intValue());
        final List<FacebookMusicListen> musicListens = profile.getMusicListens();
        assertEquals(4, musicListens.size());
        final FacebookPicture picture = profile.getPicture();
        assertFalse(picture.getIsSilhouette());
        assertEquals(36, profile.getAttributes().size());
    }
View Full Code Here

Examples of org.pac4j.oauth.profile.facebook.FacebookProfile

    protected FacebookProfile retrieveUserProfileFromToken(final Token accessToken) {
        String body = sendRequestForData(accessToken, getProfileUrl(accessToken));
        if (body == null) {
            throw new HttpCommunicationException("Not data found for accessToken : " + accessToken);
        }
        final FacebookProfile profile = extractUserProfile(body);
        addAccessTokenToProfile(profile, accessToken);
        if (profile != null && this.requiresExtendedToken) {
            String url = CommonHelper.addParameter(EXCHANGE_TOKEN_URL, OAuthConstants.CLIENT_ID, this.key);
            url = CommonHelper.addParameter(url, OAuthConstants.CLIENT_SECRET, this.secret);
            url = CommonHelper.addParameter(url, EXCHANGE_TOKEN_PARAMETER, accessToken.getToken());
View Full Code Here

Examples of org.pac4j.oauth.profile.facebook.FacebookProfile

        return profile;
    }
   
    @Override
    protected FacebookProfile extractUserProfile(final String body) {
        final FacebookProfile profile = new FacebookProfile();
        final JsonNode json = JsonHelper.getFirstNode(body);
        if (json != null) {
            profile.setId(JsonHelper.get(json, "id"));
            for (final String attribute : OAuthAttributesDefinitions.facebookDefinition.getAllAttributes()) {
                profile.addAttribute(attribute, JsonHelper.get(json, attribute));
            }
            extractData(profile, json, FacebookAttributesDefinition.FRIENDS);
            extractData(profile, json, FacebookAttributesDefinition.MOVIES);
            extractData(profile, json, FacebookAttributesDefinition.MUSIC);
            extractData(profile, json, FacebookAttributesDefinition.BOOKS);
View Full Code Here

Examples of org.pac4j.oauth.profile.facebook.FacebookProfile

    @SuppressWarnings("unused")
    public void testProfileFacebookCreation() {
        // ProfileHelper.setKeepRawData(false);
        final long t0 = System.currentTimeMillis();
        for (int i = 0; i < MAX_FACEBOOK; i++) {
            final FacebookProfile facebookProfile = benchFacebookClient.createProfile(FACEBOOK_RESPONSE);
        }
        final long t1 = System.currentTimeMillis();
        logger.warn(MAX_FACEBOOK + " Facebook profile creations took : " + (t1 - t0) + " ms");
    }
View Full Code Here

Examples of org.springframework.social.facebook.api.FacebookProfile

        }
        User user = new User();
        if (attempt != null) {
            Object api = attempt.getConnection().getApi();
            if (api instanceof Facebook) {
                FacebookProfile profile = ((Facebook) api).userOperations().getUserProfile();
                user.setEmail(profile.getEmail());
                user.setNames(profile.getName());
                user.setUsername(profile.getUsername());
            } else if (api instanceof Twitter) {
                TwitterProfile profile = ((Twitter) api).userOperations().getUserProfile();
                user.setNames(profile.getName());
                user.setUsername(profile.getScreenName());
            }
        } else {
            user.setEmail(email);
            model.addAttribute("type", "Persona");
        }
View Full Code Here

Examples of org.springframework.social.facebook.api.FacebookProfile

    assertEquals(expectedPermissions, permissions);
  }
 
  @Test
  public void getUserProfile() {
    FacebookProfile profile = fb.userOperations().getUserProfile();
    assertEquals(testUser.getId(), profile.getId());
    assertEquals("Jack Diamond", profile.getName());
    assertEquals("Jack", profile.getFirstName());
    assertEquals("Diamond", profile.getLastName());
    assertEquals("08/08/1980", profile.getBirthday());
    assertEquals("https://www.facebook.com/profile.php?id="+testUser.getId(), profile.getLink());
    assertEquals(new Locale("en", "US"), profile.getLocale());
    assertEquals(0.0f, (float) profile.getTimezone(), 0.0f);
    assertFalse(profile.isVerified());
    assertNotNull(profile.getUpdatedTime()); // TODO : Verify time is (within reason) near the current time
   
    // some data is randomly generated for the test user, so tests cannot be precise
    assertTrue(profile.getEmail().matches("jack_(.*)_diamond@tfbnw.net"));
    assertTrue(profile.getGender().equals("male") || profile.getGender().equals("female"));
  }
View Full Code Here

Examples of org.springframework.social.facebook.api.FacebookProfile

    assertTrue(profile.getGender().equals("male") || profile.getGender().equals("female"));
  }
 
  @Test
  public void getUserProfile_byUserId() {
    FacebookProfile profile = fb.userOperations().getUserProfile(testUser.getId());
    assertEquals(testUser.getId(), profile.getId());
    assertEquals("Jack Diamond", profile.getName());
    assertEquals("Jack", profile.getFirstName());
    assertEquals("Diamond", profile.getLastName());
    assertEquals("08/08/1980", profile.getBirthday());
    assertEquals("https://www.facebook.com/profile.php?id="+testUser.getId(), profile.getLink());
    assertEquals(new Locale("en", "US"), profile.getLocale());
    assertEquals(0.0f, (float) profile.getTimezone(), 0.0f);
    assertFalse(profile.isVerified());
    assertNotNull(profile.getUpdatedTime()); // TODO : Verify time is (within reason) near the current time
   
    // some data is randomly generated for the test user, so tests cannot be precise
    assertTrue(profile.getEmail().matches("jack_(.*)_diamond@tfbnw.net"));
    assertTrue(profile.getGender().equals("male") || profile.getGender().equals("female"));
  }
View Full Code Here

Examples of org.springframework.social.facebook.api.FacebookProfile

  @Test
  public void getUserProfile_byUserId_someOtherUser() {
    TestUser mimi = createTestUser("Mimi Kaboom", ALL_PERMISSIONS);
   
    FacebookProfile profile = fb.userOperations().getUserProfile(mimi.getId());
    assertEquals(mimi.getId(), profile.getId());
    assertEquals("Mimi Kaboom", profile.getName());
    assertEquals("Mimi", profile.getFirstName());
    assertEquals("Kaboom", profile.getLastName());
    assertNull(profile.getBirthday());
    assertEquals("https://www.facebook.com/profile.php?id="+mimi.getId(), profile.getLink());
    assertEquals(new Locale("en", "US"), profile.getLocale());
    assertNull(profile.getTimezone());
    assertNull(profile.isVerified());
    assertNotNull(profile.getUpdatedTime()); // TODO : Verify time is (within reason) near the current time
   
    // some data is randomly generated for the test user, so tests cannot be precise
    assertNull(profile.getEmail());
    assertTrue(profile.getGender().equals("male") || profile.getGender().equals("female"));
    deleteTestUser(mimi);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.