com.stackmob.sdkapi
Interface FacebookService


public interface FacebookService

The Facebook service.


Method Summary
 boolean createUserWithFacebookId(String modelName, String username, String accessToken)
          Creates a new user object, using the given facebook token for authentication.
 String findUser(String modelName, String accessToken)
          Find the username assigned to the Facebook user ID contained in the given access token.
 boolean linkFacebookIdToUser(String modelName, String username, String accessToken)
          Assigns the Facebook user ID contained in the access token to the user with the given username.
 String publishMessage(String modelName, String username, String messageText)
          Post a message to a user's Facebook wall.
 

Method Detail

createUserWithFacebookId

boolean createUserWithFacebookId(String modelName,
                                 String username,
                                 String accessToken)
                                 throws FacebookServiceException
Creates a new user object, using the given facebook token for authentication. The user will be assigned the Facebook ID, containted in the access token, which may be used to authenticate the user in the future.

Parameters:
modelName - the name of the relevant object model; must be a type already declared for the current application
username - a new unique username in your schema. A user object with this username will be created
accessToken - the Facebook acess token
Returns:
true if the operation was successful, false if a user could not be created
Throws:
FacebookServiceException - if the username already exists, or the facebook user id is already assigned to another user, or a datastore error occurs

linkFacebookIdToUser

boolean linkFacebookIdToUser(String modelName,
                             String username,
                             String accessToken)
                             throws FacebookServiceException
Assigns the Facebook user ID contained in the access token to the user with the given username. The access token may be used to authenticate the user in the future.

Parameters:
modelName - the name of the relevant object model; must be a type already declared for the current application
username - the user, which should be assigned the facebook credentials
accessToken - the Facebook access token
Returns:
ture if the operation was successful, false if a user with the given name does not exist
Throws:
FacebookServiceException - if the Facebook user ID is already assigned to another user, or a datastore error occurs

findUser

String findUser(String modelName,
                String accessToken)
                throws FacebookServiceException
Find the username assigned to the Facebook user ID contained in the given access token.

Parameters:
modelName - the name of the relevant object model; must be a type already declared for the current application
accessToken - the Facebook access token
Returns:
The username corresponding to the Facebook credentials, or null, if the user is not found
Throws:
FacebookServiceException - if a datastore error occurs

publishMessage

String publishMessage(String modelName,
                      String username,
                      String messageText)
                      throws FacebookServiceException
Post a message to a user's Facebook wall.

Parameters:
modelName - the name of the relevant object model; must be a type already declared for the current application
username - the user, on whose wall the message will be posted
messageText - the message to post
Returns:
id of the message, or null if the operation did not succeed
Throws:
FacebookServiceException - if the user is not assinged a Facebook ID, or if an authentication error, or a datastore error occurred


Copyright © 2012 StackMob. All Rights Reserved.