Game Development Reference
In-Depth Information
Most Graph API values will require you to specify an access token to show that
your application is authorized to make requests. The access token is provided
to our application as part of the login process and we can retrieve it using the
s3eFBSession_AccessToken function, which again takes the session pointer as its
sole input. The access token is returned as a const char pointer.
The access token can then be added to a Graph request using the s3eFBRequest_
AddParamString function by specifying access_token for the parameter name and
using the return value from the s3eFBSession_AccessToken function as the value
for the parameter.
Once all parameters have been added to the request, we can send it to the Facebook
servers using the s3eFBRequest_Send function. This function takes the request
pointer as its first input, followed by a callback function and a pointer to an optional
block of data that will be passed to the callback function when it is triggered.
The function will return immediately with S3E_RESULT_SUCCESS if the request was
sent, or S3E_RESULT_ERROR if there was a problem transmitting it. The s3eFacebook
API will wait for the request from Facebook to arrive and will call the specified
callback function with the result when it does.
When a request is completed we should make a call to s3eFBRequest_Delete to free
any resources associated with it.
Let's look at an example illustrating all of the previous points for posting a simple
message to the user's wall:
// Sample callback function for s3eFBRequest_Send function
void RequestCallback(struct s3eFBRequest* apRequest,
s3eResult* apRequestResult, void* apUserData)
{
if (*apRequestResult == S3E_RESULT_SUCCESS)
{
// Request successful
}
else
{
// Request failed
}
// Free the request resources
s3eFBRequest_Delete(apRequest);
}
// The following code snippet illustrates how we can send a request
 
Search WWH ::




Custom Search