Package com.restfb

Examples of com.restfb.FacebookClient


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


    return null;
  }
 
  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

    return null;
  }
 
  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

    return null;
  }
 
  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

  }
 
  @SuppressWarnings("unused")
  public static void publishScore(String score, String userId) {
    Long realScore = Long.valueOf(score);
    FacebookClient facebookClient = new DefaultFacebookClient(Constants.APP_ACCES_TOKEN);
    Boolean publishScoreResponse = facebookClient.publish(userId +"/scores", Boolean.class,
        Parameter.with("score", realScore.intValue()));
  }
View Full Code Here

   
    Player player = DatastoreHelper.getPlayer(username);
   
    String accessToken = player.getAccessToken();
   
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    FacebookType postScoreToWallResponse = facebookClient.publish("me/feed", FacebookType.class,
        Parameter.with("message", "just scored " + score + " on stewiemaze"));
   
  }
View Full Code Here

    Long realScore = player.getHighscore();
   
    String accessToken = player.getAccessToken();
    String score = player.getHighscore() + "";
   
    FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
    FacebookType postScoreToWallResponse = facebookClient.publish("me/feed", FacebookType.class,
        Parameter.with("message", message));
   
  }
View Full Code Here

  private FacebookClient createFacebookClient(String accessToken) {
    return new DefaultFacebookClient(accessToken);
  }
 
  public Boolean exist(String accessToken, String facebookId) {
    FacebookClient fb = createFacebookClient(accessToken);
    Connection<User> connection = fb.fetchConnection(FB_SEARCH, User.class, Parameter.with(FB_ID, facebookId));
    return !connection.getData().isEmpty();
  }
View Full Code Here

    Connection<User> connection = fb.fetchConnection(FB_SEARCH, User.class, Parameter.with(FB_ID, facebookId));
    return !connection.getData().isEmpty();
  }
 
  public User getProfile(String accessToken) {
    FacebookClient fb = createFacebookClient(accessToken);
    return fb.fetchObject(FB_ME, User.class);
  }
View Full Code Here

  public Boolean isFriend(String accessToken, String facebookId) {
    return getFriend(accessToken, facebookId) != null;
  }
 
  public User getFriend(String accessToken, String facebookId) throws FacebookOAuthException {
    FacebookClient fb = createFacebookClient(accessToken);
    List<User> users = fb.executeFqlQuery(FRIEND_FQL.replaceAll(FRIEND_FQL_REPLACEMENT, facebookId), User.class);
    try {
      return users.iterator().next();
    } catch (NoSuchElementException e) {
      return null;
    }
View Full Code Here

TOP

Related Classes of com.restfb.FacebookClient

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.