Game Development Reference
In-Depth Information
After authorizing (or indeed disallowing) the Facebook App, our application will
regain focus and the login callback function will be triggered to say whether the
process was successful or not. If the Facebook app was not authorized or there is no
Internet connection available, login will fail.
Logging back out of Facebook again is also simple. All we have to do is make a call
to
s3eFBSession_Logout
, passing the
s3eFBSession
pointer as its only argument.
In practice we only ever need to log out of Facebook on closing our application or if
you specifically want to log off to allow different user credentials to be used instead.
The session will not expire or become invalid as long as our application is executing.
Posting a message to a user's wall
We'll now take a look at one of the most common things that games use Facebook
for: posting a message to the user's wall to alert their friends to a new high score or
some in-game achievement.
In order to do this we'll be making use of the Facebook Graph API. There are other
ways, but the Graph API is the most up-to-date way of doing so and doesn't look
likely to be replaced any time soon.
For more information on the Facebook Graph API take a look at the web
page
http://developers.facebook.com/docs/reference/
api/
, and for details about wall posts take a look at
http://
developers.facebook.com/docs/reference/api/post/
.
To begin making a Facebook Graph API request, we use the function
s3eFBRequest_
WithGraphPath
. This function takes as arguments the session pointer, the desired
Facebook Graph path, and the HTTP method to use (GET or POST). The Graph path
and HTTP method are both specified as null-terminated strings.
The function will return a pointer to an
s3eFBRequest
structure representing the
new request if it is successful, or
NULL
if it fails.
With the request structure created, we can now add the various parameters we
need to it using the functions
s3eFBRequest_AddParamNumber
and
s3eFBRequest_
AddParamString
. Both functions take the
s3eFBRequest
structure pointer and a
null-terminated string for the parameter name as their first two parameters. The
third parameter is a 64-bit integer value (Marmalade defines a type called
int64
for
this) for the former function call, or a
const char
pointer to a null terminated string
for the latter function.
Search WWH ::
Custom Search