Online Book Reader

Home Category

iPhone Game Development - Chris Craft [89]

By Root 1600 0
= [user objectForKey:@”name”];

UIAlertView *alert =

[[UIAlertView alloc] initWithTitle:nil message:name delegate:self

cancelButtonTitle:@”OK” otherButtonTitles:nil];

[alert show];

[alert release];

}

There are currently ten extended permissions that your application can request. Each extended permission must be authorized by a user individually. In other words, you cannot request more than one extended permission at a time without showing the FBPermissionDialog multiple times.

Here is a listing of available extended permissions:

email. Allows an application to send e-mail to the logged in user

offline_access. Allows an application to access a user's data even when the user is not online and does not have an active session

status_update. Grants an application permission to set the user's Facebook status

photo_update. Allows the application to post photos to the user's profile without the user having to approve them

create_event. Grants an app permission to create and modify events for the user

rsvp_event. Allows an application permission to RSVP to an event for the user

sms. Allows an application the ability to send and respond to the user via text messages

video_upload. Allows an app a way to upload videos to post videos to the user's Facebook profile

create_note. Allows the application to write, edit, and delete notes on the user's profile

share_item. Grants an application the right to post links to the profile of the logged-in user

Publishing feed stories

The ability to publish stories to a user's profile is one of the most exciting features you gain by using the Facebook Connect API. The key to publishing your application's story to your user's profile is the FBFeedDialog object. You can see the screen that is generated from this code in Figure 6.31:

FBFeedDialog* dialog = [[[FBFeedDialog alloc] init] autorelease];

dialog.delegate = self;

dialog.templateBundleId = 30126546835;

dialog.templateData = @”{\”score\”: \”53324\”, \”rank\”: \”Captain\”}”;

[dialog show];

FIGURE 6.31

Publishing your application's story to your user's profile.


Using the Facebook Platform API

You can use the Facebook Platform API directly from the iPhone or you can use it remotely from servers of your own. The advantage of using it from the iPhone is convenience; the advantage of using your own servers is power and flexibility. If you want to use your own servers, you would send the session key and the session secret to your servers, and have them return the result. The following code shows you how to use the Facebook Connect API to call the Facebook Platform API to get the user's name:

- (void)getUserName

{

NSString* fql = @”select name from user where uid == 1234”;

NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@”query”];

[[FBRequest requestWithDelegate:self] call:@”facebook.fql.query” params:params];

}

- (void)request:(FBRequest*)request didLoad:(id)result

{

NSArray* users = result;

NSDictionary* user = [users objectAtIndex:0];

NSString* name = [user objectForKey:@”name”];

NSLog(@”Query returned %@”, name);

}

The full Facebook Platform API is a much richer, more complete, and more powerful API compared to the Facebook Connect API. Whatever functionality Facebook lets developers have access to can be accomplished through using the Facebook Platform APIs.

Tip

You can learn more about the Facebook Platform APIs at http://wiki.developers.facebook.com/index.php/API. This is where the developer's wiki is located with information regarding all of the API methods.

Notice how the Connect to Facebook dialog box uses information from your iPhone Test App's settings. The application name is shown to the user in the text at the top of the screen. Additionally, your application's logo image is displayed in the dialog box. By doing this, Facebook announces your application to users using text and images.

By taking advantage of Facebook Connect for iPhone, you have let Facebook do

Return Main Page Previous Page Next Page

®Online Book Reader