Package com.restfb.types

Examples of com.restfb.types.User$Sport


      return null;
    }
   
    Player player = DatastoreHelper.getPlayer(username);
    if (player == null) {
      User user = FacebookHelper.getUser(accessToken);
      Player newFacebookPlayer = PlayerService.createFacebookPlayer(username, user.getId(), user.getEmail(), new Long(0));
      RegisterPlayerService.registerPlayer(newFacebookPlayer);
      DatastoreHelper.updateAccessToken(username, accessToken);
      FacebookHelper.postMessageToWall(username, "just registered to stewiemaze");
    }
    return username;
View Full Code Here


public class FacebookHelper {

  public static String getUsername(String accessToken) {
   
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    User user = facebookClient.fetchObject("me", User.class);
    if (user != null) {
      return user.getName();
    }
    return null;
  }
View Full Code Here

  }
 
  public static String getUserId(String accessToken) {
   
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    User user = facebookClient.fetchObject("me", User.class);
    if (user != null) {
      return user.getId();
    }
    return null;
  }
View Full Code Here

  }
 
  public static String getEmail(String accessToken) {
   
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    User user = facebookClient.fetchObject("me", User.class);
    if (user != null) {
      return user.getEmail();
    }
    return null;
  }
View Full Code Here

  }
 
  public static User getUser(String accessToken) {
   
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    User user = facebookClient.fetchObject("me", User.class);
    if (user != null) {
      return user;
    }
    return null;
  }
View Full Code Here

    public Response facebookLogin(@QueryParam("access_token") String access_token) {
        String appId = env.get("facebook.appId");
        String appSecret = env.get("facebook.appSecret");
        try {
            FacebookClient facebookClient = new DefaultFacebookClient(access_token);
            User user = facebookClient.fetchObject("me", User.class);

            String me = "";
            try {
                me = gson.toJson(user);
            } catch (Exception e) {
                e.printStackTrace();
            }

            Guest guest = guestService.getGuest(user.getUsername());
            final String autoLoginToken = generateSecureRandomString();
            if (guest==null) {
                FacebookClient.AccessToken accessToken =
                        new DefaultFacebookClient().obtainExtendedAccessToken(appId, appSecret, access_token);
                String firstname = user.getFirstName();
                String lastname = user.getLastName();
                guest = guestService.createGuest(user.getUsername(), firstname!=null?firstname:"",
                                                 lastname!=null?lastname:"",
                                                 null, user.getEmail(),
                                                 Guest.RegistrationMethod.REGISTRATION_METHOD_FACEBOOK, null);
                final ApiKey apiKey = guestService.createApiKey(guest.getId(), Connector.getConnector("facebook"));

                guestService.setApiKeyAttribute(apiKey, "accessToken", accessToken.getAccessToken());
                guestService.setApiKeyAttribute(apiKey, "expires", String.valueOf(accessToken.getExpires().getTime()));
View Full Code Here

  }

  public void fetchObject() {
    out.println("* Fetching single objects *");

    User user = facebookClient.fetchObject("me", User.class);
    Page page = facebookClient.fetchObject("cocacola", Page.class);

    out.println("Name: " + user.getName());
    out.println("Username: " + user.getUsername());
    out.println("Email: " + user.getEmail());
    out.println("ID Facebook: " + user.getId());
    out.println("About: " + user.getAbout());
    out.println("Birthday: " + user.getBirthday());
   
    //out.println("Page likes: " + page.getLikes());
  }
View Full Code Here

    // Make the API call
    JsonObject results = facebookClient.fetchObjects(ids, JsonObject.class);

    // Pull out JSON data by key and map each type by hand.
    JsonMapper jsonMapper = new DefaultJsonMapper();
    User user = jsonMapper.toJavaObject(results.getString("btaylor"), User.class);
    Url url = jsonMapper.toJavaObject(results.getString("http://www.imdb.com/title/tt0117500/"), Url.class);

    out.println("User is " + user);
    out.println("URL is " + url);
  }
View Full Code Here

  }

  public void metadata() {
    out.println("* Metadata *");

    User userWithMetadata = facebookClient.fetchObject("me", User.class, Parameter.with("metadata", 1));

    out.println("User metadata: has albums? " + userWithMetadata.getMetadata().getConnections().hasAlbums());
  }
View Full Code Here

  }

  public void selection() {
    out.println("* Selecting specific fields *");

    User user = facebookClient.fetchObject("me", User.class, Parameter.with("fields", "id,name"));

    out.println("User name: " + user.getName());
  }
View Full Code Here

TOP

Related Classes of com.restfb.types.User$Sport

Copyright © 2018 www.massapicom. 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.