Online Book Reader

Home Category

iPhone Game Development - Chris Craft [80]

By Root 1538 0

// This application will not work until you enter your Facebook application's API key here:

static NSString* kApiKey = @””;

// Enter either your API secret or a callback URL (as described in documentation):

static NSString* kApiSecret = nil; // @””;

static NSString* kGetSessionProxy = nil; // @””;

///////////////////////////////////////////////////////////////////////////////////////////////////

}

You will need to replace the text with your actual API key, and you will need to update with your actual secret key. You can find both your API key and your secret key on your iPhone Test App's settings page.

Notice how Facebook allows you to provide either your API secret or a callback URL. Since you want to use your secret key, be sure to uncomment the section of code that assigns your secret key to the kApiSecret variable by removing the two leading forward slashes from that line. When you are done, your code should look similar to the following code listing. The only real difference should be your API key and secret:

#import “SessionViewController.h”

#import “FBConnect/FBConnect.h”

////////////////////////////////////////////////////////////////////////////////

// This application will not work until you enter your Facebook application's API key here:

static NSString* kApiKey = @”0123456789abcdefghijklmnopqrstuv”;

// Enter either your API secret or a callback URL (as described in documentation):

static NSString* kApiSecret = @”abcdefghijklmnopqrstuv0123456789”;

static NSString* kGetSessionProxy = nil; // @””;

///////////////////////////////////////////////////////////////////////////////////////////////////

}

Now, if you click the Build and Go button in Xcode, you should see a screen appear on your iPhone with a button labeled Connect with Facebook. Click this button to bring up the Connect to Facebook screen, where you can connect your sample iPhone application to your iPhone Test App Facebook application (Figure 6.12).

FIGURE 6.12

Connect to Facebook


Tip

There is an official free Facebook iPhone application on the App Store. It's a great example of what can be done in an iPhone application. Be sure to check it out.

Once you have logged in to Facebook Connect by entering your Facebook e-mail and password credentials, you will see a screen like the one shown in Figure 6.13. The sample iPhone Facebook Connect application has a few options available for you to test. Even though it is very basic, it really delivers the key features and functionality you will need to implement in your iPhone applications, so feel free to explore its details.

FIGURE 6.13

Logged in to Facebook Connect


You should see a label in the center of the screen that indentifies who you are logged in as. At the top of the screen is the Facebook Logout button, and in the bottom half of the screen are two large buttons: Get Permission and Publish to Feed.

Creating a feed template

Before you can fully experience all the features of the sample iPhone Facebook Connect application, you still have a little more work left to complete. In order for the Publish to Feed button to work, you need to create at least one feed template for your Facebook application. Go back to the Facebook Developers page located at www.facebookcom/developers. Open your iPhone Test App on Facebook and go back to Edit Settings. From here click on the Connect tab on the left-hand side of the page. If you scroll down the page, you should locate the Template Bundles section, as shown in Figure 6.14.

FIGURE 6.14

Template Bundles section


You can also create feed templates using the Feed Template Console tool. To find this useful tool, go to http://developersfacebookcom, click the Tools button at the top of the screen, and then click on the Feed Template Console tab. Or you can access the tool directly by going to http://developers.facebook.com/tools.php?feed.

Tip

Learn all the details of creating template feeds

Return Main Page Previous Page Next Page

®Online Book Reader