Saturday, January 15, 2011

Facebook Connect on IPhone - Part 1

Tried a bit of Facebook Connect IPhone App programming today which didn't go as successful as I hope because I was initially confused by two sets of Facebook Connect APIs which are currently available.

The older version released prior to Dec 2010 which is explained by tutorials such as this:
http://www.mobisoftinfotech.com/blog/iphone/iphone-fbconnect-facebook-connect-tutorial/

The LATEST version, released in Dec 2010 available here
https://github.com/facebook/facebook-ios-sdk

It's always better to work with the latest version,  so without hesitation, I went for the second version.

Fortunately, there was a step-by-step guide for that API, so I thought it would be a breeze to get started if I just followed the steps as explained in the guide.

Step 1 looked deceivingly easy.  Install the GIT installler, and use the software to download the latest version of the Facebook Connect build.  But ended up, it wasn't so! Well, downloading it was the easiest part.  I did so at the Google page here: GIT installer Page.  Since I was on a Macbook Air (2010 version) with Mac OS 10.6.5, I chose the version right on top: "git-1.7.3.5-i386-leopard.dmg".

After that, I just double clicked the DMG to install it, and thought I can quickly get started to download the code by looking for the application in "/usr/local/git/bin" which was supposed to be the default path the application will be kept.  Navigated to the folder, but couldn't find it :(

Navigated to other possible folders.  Still couldn't find git.  SPOTLIGHT couldnt find it either.  It only managed to find the DMG file I downloaded! Wasted at least 30 minutes doing this before I gave up and decided on the more practical solution.

What I ended up doing was to open up a Terminal window with SPOTLIGHT, type "git https://github.com/facebook/facebook-ios-sdk.git" at the command-line, and lo-and-behold, the SDK was instantly downloaded to my Documents folder. Phew. Finally.

What came after that is a LOONG story, but happy to say, after countless debugging, I managed to successfully to do a login to Facebook as shown in the screens below.

I will be sharing some snippets of code in my next few posts as I get more familiar with this API but meanwhile, if you are interested, here are some good links to follow:

http://thinkdiff.net/facebook/how-to-develop-facebook-application-for-iphone/
Facebook Graph API : http://developers.facebook.com/docs/reference/api/


Initial appearance

Facebook Login screen is automatically shown when the prev button is clicked

Your permission will be sought to authorize the App

The status is shown as "Logged in" and a button "Get User Info" is added

The label is updated to display user name when the "Get User Info" button is clicked

No comments:

Post a Comment