Package com.restfb

Examples of com.restfb.DefaultFacebookClient


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 static String FB_LINK = "link";
  private static String FB_PICTURE = "picture";
  private static String FB_DESC = "description";
 
  private FacebookClient createFacebookClient(String accessToken) {
    return new DefaultFacebookClient(accessToken);
  }
View Full Code Here

    }
    else {
      log.info("...success");
      log.info("Create new facebook client...");
      facebookClient = new DefaultFacebookClient(oauthToken);
      log.info("...success");
      log.info("Attempt get friendlist by fetchConnection...");
      Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class);
      log.info("...success");
      writer.print("<body bgcolor='yellow'>");
View Full Code Here

    @Path("/login")
    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(),
View Full Code Here

TOP

Related Classes of com.restfb.DefaultFacebookClient

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.