Game Development Reference
In-Depth Information
Checking for s3eFacebook support
As previously mentioned, the s3eFacebook API is only supported on iOS and
Android, so it's good to be able to check at runtime whether we can support
Facebook or not. This is easily done using the s3eFacebookAvailable function,
which will return S3E_TRUE if the API is available or S3E_FALSE if it isn't.
Initialization and termination
Before we can call any of the s3eFacebook APIs, we must first initialize a Facebook
session. We do this with a call to the function s3eFBInit that takes a single parameter,
a null-terminated string containing the App Id of the Facebook App we want to use.
The function will return a pointer to an s3eFBSession instance, which we will need
to use to access the Facebook API and make requests to it.
We can release the Facebook session with a call to s3eFBTerminate , which takes the
session pointer returned from s3eFBInit as its only argument.
It is sufficient to call the s3eFBInit function the first time we want to make any
Facebook request and then to use this same session information for the execution
life of our application. The s3eFBTerminate function only needs to be called at
shutdown time.
Logging in and out of Facebook
Before we can make any Facebook request, we must first log in to Facebook. This
is done with the s3eFBSession_LogIn function, which takes five parameters. The
first is the s3eFBSession pointer returned from s3eFBInit . We can then specify
a callback function, which will be triggered once successfully logged in. A pointer
to a block of user data can also be specified, which will be passed into the callback
function when it is triggered.
The callback function can be specified as NULL , in which case we need to check for
login to be completed by calling the s3eFBSession_LoggedIn function. This takes
the session pointer as an argument and will return S3E_TRUE when the session is
logged in.
The final two parameters of s3eFBSession_LogIn are an array of null-terminated
strings listing the Facebook API permissions we want to make use of and the number
of permissions in this array. Permissions allow our application to notify the user
that our application wants to perform certain operations on their account, such as
posting to their wall or accessing their photo collection. A full list of permissions
can be found at the web page http://developers.facebook.com/docs/
authentication/permissions/ .
 
Search WWH ::




Custom Search