com.stackmob.sdk.api
Class StackMob

java.lang.Object
  extended by com.stackmob.sdk.api.StackMob

public class StackMob
extends Object


Nested Class Summary
protected static class StackMob.RegistrationIDAndUser
           
 
Field Summary
protected  StackMobRedirectedCallback redirectedCallback
           
protected  StackMobRedirectedCallback userRedirectedCallback
           
 
Constructor Summary
StackMob(String apiKey, String apiSecret, String userObjectName, Integer apiVersionNumber)
          create a new StackMob object
StackMob(String apiKey, String apiSecret, String userObjectName, Integer apiVersionNumber, String urlFormat, StackMobRedirectedCallback redirectedCallback)
          create a new StackMob object.
StackMob(String apiKey, String apiSecret, String userObjectName, String appName, Integer apiVersionNumber)
          create a new StackMob object.
 
Method Summary
 void delete(String path, String id, StackMobCallback callback)
          do a delete request to the stackmob platform
 void endSession(StackMobCallback callback)
          call the endsession method on stackmob
 void facebookLogin(String token, StackMobCallback callback)
          login into facebook on the StackMob platform
 void facebookPostMessage(String msg, StackMobCallback callback)
          post a message to facebook
 void get(String path, HashMap<String,Object> arguments, StackMobCallback callback)
          do a get request on the StackMob platform
 void get(String path, StackMobCallback callback)
          do a get request on the StackMob platform
 void getFacebookUserInfo(StackMobCallback callback)
          get facebook user info for the current user
 StackMobSession getSession()
          get the session that this StackMob object contains
 void linkUserWithFacebookToken(String token, StackMobCallback callback)
          link an existing StackMob user with a Facebook user
 void linkUserWithTwitterToken(String token, String secret, StackMobCallback callback)
          link an existing stackmob user with an existing twitter user
 void login(HashMap<String,Object> params, StackMobCallback callback)
          call the login method on StackMob
 void logout(StackMobCallback callback)
          call the logout method on StackMob
 void post(String path, Object requestObject, StackMobCallback callback)
          do a post request on the StackMob platform
 void put(String path, String id, Object requestObject, StackMobCallback callback)
          do a put request on the StackMob platform
 void registerForPushWithUser(String username, String registrationID, StackMobCallback callback)
          register a user for C2DM push notifications
 void registerWithFacebookToken(String token, String username, StackMobCallback callback)
          create a new StackMob user and link that user with a facebook account
 void registerWithTwitterToken(String token, String secret, String username, StackMobCallback callback)
          create a new user on stackmob and associate it with an existing twitter user
 void startSession(StackMobCallback callback)
          call the startsession method on StackMob
 void twitterLogin(String token, String secret, StackMobCallback callback)
          call the twitterlogin method on stackmob
 void twitterStatusUpdate(String message, StackMobCallback callback)
          call the twitterStatusUpdate method on StackMob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userRedirectedCallback

protected StackMobRedirectedCallback userRedirectedCallback

redirectedCallback

protected StackMobRedirectedCallback redirectedCallback
Constructor Detail

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                String appName,
                Integer apiVersionNumber)
create a new StackMob object. this is the preferred constructor

Parameters:
apiKey - the api key for your app
apiSecret - the api secret for your app
userObjectName - the name of your app's user object. if you do not have a user object, pass the empty strinrg here and do not use the login, logout, facebook or twitter methods, as they will fail
appName - the name of your application
apiVersionNumber - the version of your app's API that you want to use with this StackMob session. pass 0 for sandbox

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                Integer apiVersionNumber)
create a new StackMob object

Parameters:
apiKey - the api key for your app
apiSecret - the api secret for your app
userObjectName - the name of your app's user object. if you do not have a user object, pass the empty string here and do not use the login, logout, facebook or twitter methods, as they will fail
apiVersionNumber - the version of your app's API that you want to use with this StackMob session. pass 0 for sandbox

StackMob

public StackMob(String apiKey,
                String apiSecret,
                String userObjectName,
                Integer apiVersionNumber,
                String urlFormat,
                StackMobRedirectedCallback redirectedCallback)
create a new StackMob object. use this constructor if you do your own caching of URLs for redirection

Parameters:
apiKey - the api key for your app
apiSecret - the api secret for your app
userObjectName - the name of your app's user object
apiVersionNumber - the version number of your app's API that you want to use with this object. pass 0 for sandbox
urlFormat - the format of URLs to use. for instance: api.mob1.stackmob.com
redirectedCallback - callback to be called if the StackMob platform issues a redirect. you should use this callback to cache the new URLs. here is a sample callback: new StackMobRedirectedCallback() { public void redirected(HttpRequest origRequest, HttpResponse response, HttpRequest newRequest) { try { URI uri = new URI(newRequest.getRequestLine().getUri()); cache(uri.getHost); } catch (URISyntaxException e) { handleException(e); } } } } note that this callback may be called in a background thread
Method Detail

login

public void login(HashMap<String,Object> params,
                  StackMobCallback callback)
call the login method on StackMob

Parameters:
params - parameters to pass to the login method
callback - callback to be called when the server returns. may happen in a separate thread

logout

public void logout(StackMobCallback callback)
call the logout method on StackMob

Parameters:
callback - callback to be called when the server returns. may happen in a separate thread

startSession

public void startSession(StackMobCallback callback)
call the startsession method on StackMob

Parameters:
callback - callback to call when the method completes

endSession

public void endSession(StackMobCallback callback)
call the endsession method on stackmob

Parameters:
callback - callback to be called when the server returns. may happen in a separate thread

twitterLogin

public void twitterLogin(String token,
                         String secret,
                         StackMobCallback callback)
call the twitterlogin method on stackmob

Parameters:
token - the twitter session key (this is a per user key - different from the consumer key)
secret - the twitter session secret (this is a per user secret - different from the consumer secret)
callback - callback to be called when the server returns. may happen in a separate thread

twitterStatusUpdate

public void twitterStatusUpdate(String message,
                                StackMobCallback callback)
call the twitterStatusUpdate method on StackMob

Parameters:
message - the message to send. must be <= 140 characters
callback - callback to be called when the server returns. may happen in a separate thread

registerWithTwitterToken

public void registerWithTwitterToken(String token,
                                     String secret,
                                     String username,
                                     StackMobCallback callback)
create a new user on stackmob and associate it with an existing twitter user

Parameters:
token - the twitter session key (this is a per user key - different from the consumer key)
secret - the twitter session secret (this is a per user secret - different from the consumer secret)
username - the username that the user should have
callback - callback to be called when the server returns. may happen in a separate thread

linkUserWithTwitterToken

public void linkUserWithTwitterToken(String token,
                                     String secret,
                                     StackMobCallback callback)
link an existing stackmob user with an existing twitter user

Parameters:
token - the twitter session key (this is a per user key - different from the consumer key)
secret - the twitter session secret (this is a per user secret - different from the consumer secret)
callback - callback to be called when the server returns. may happen in a separate thread

facebookLogin

public void facebookLogin(String token,
                          StackMobCallback callback)
login into facebook on the StackMob platform

Parameters:
token - the facebook user token
callback - callback to be called when the server returns. may happen in a separate thread

registerWithFacebookToken

public void registerWithFacebookToken(String token,
                                      String username,
                                      StackMobCallback callback)
create a new StackMob user and link that user with a facebook account

Parameters:
token - the facebook user token
username - the StackMob username that the new user should have
callback - callback to be called when the server returns. may happen in a separate thread

linkUserWithFacebookToken

public void linkUserWithFacebookToken(String token,
                                      StackMobCallback callback)
link an existing StackMob user with a Facebook user

Parameters:
token - the Facebook user token
callback - callback to be called when the server returns. may happen in a separate thread

facebookPostMessage

public void facebookPostMessage(String msg,
                                StackMobCallback callback)
post a message to facebook

Parameters:
msg - the message to post
callback - callback to be called when the server returns. may happen in a separate thread. will not post to FB and will return nothing if there is no user logged into FB

getFacebookUserInfo

public void getFacebookUserInfo(StackMobCallback callback)
get facebook user info for the current user

Parameters:
callback - callback to be called when the server returns. may happen in a separate thread. will return nothing if there is no currently logged in FB user

registerForPushWithUser

public void registerForPushWithUser(String username,
                                    String registrationID,
                                    StackMobCallback callback)
register a user for C2DM push notifications

Parameters:
username - the StackMob username to register
registrationID - the C2DM registration ID. see http://code.google.com/android/c2dm/#registering for detail on how to get this ID
callback - callback to be called when the server returns. may happen in a separate thread

get

public void get(String path,
                StackMobCallback callback)
do a get request on the StackMob platform

Parameters:
path - the path to get
callback - callback to be called when the server returns. may happen in a separate thread

get

public void get(String path,
                HashMap<String,Object> arguments,
                StackMobCallback callback)
do a get request on the StackMob platform

Parameters:
path - the path to get
arguments - arguments to be encoded into the query string of the get request
callback - callback to be called when the server returns. may happen in a separate thread

post

public void post(String path,
                 Object requestObject,
                 StackMobCallback callback)
do a post request on the StackMob platform

Parameters:
path - the path to get
requestObject - the object to serialize and send in the POST body. this object will be serialized with Gson
callback - callback to be called when the server returns. may happen in a separate thread

put

public void put(String path,
                String id,
                Object requestObject,
                StackMobCallback callback)
do a put request on the StackMob platform

Parameters:
path - the path to put
id - the id of the object to put
requestObject - the object to serialize and send in the PUT body. this object will be serialized with Gson
callback - callback to be called when the server returns. may happen in a separate thread

delete

public void delete(String path,
                   String id,
                   StackMobCallback callback)
do a delete request to the stackmob platform

Parameters:
path - the path to delete
id - the id of the object to put
callback - callback to be called when the server returns. may happen in a separate thread

getSession

public StackMobSession getSession()
get the session that this StackMob object contains

Returns:
the session


Copyright © 2011 StackMob. All Rights Reserved.