Tuesday, December 13, 2011

Facebook Integration all feature URL in xcode

Integrating Connect into your project

Facebook Connect is compiled as a static library, and the easiest way to add it to your project is to use Xcode's "dependent project" facilities. Here is how:
  1. Clone the repository and make sure you store it in a permanent place, because Xcode will need to reference the files every time you compile your project.
  2. Drag and drop the "FBConnect.xcodeproj" file under "facebook-iphone-sdk/src" onto the root of your Xcode project's "Groups and Files" sidebar.
  3. A dialog will appear -- make sure "Copy items" is unchecked and "Reference Type" is "Relative to Project" before clicking "Add".
  4. Link the FBConnect static library to your project:
    • Doubleclick the "FBConnect.xcodeproj" item that has just been added to the sidebar
    • Go to the "Details" table and you will see a single item: libFBConnect.a.
    • Check the checkbox on the far right of libFBConnect.a.
  5. Add FBConnect as a dependency of your project, so Xcode compiles it whenever you compile your project:
    • Expand the "Targets" section of the sidebar and double-click your application's target.
    • Go to the "General" tab and you will see a "Direct Dependencies" section.
    • Click the "+" button, select "FBConnect", and click "Add Target".
  6. Tell your project where to find the FBConnect headers:
    • Open your "Project Settings" and go to the "Build" tab.
    • Look for "Header Search Paths" and doubleclick it.
    • Add the relative path from your project's directory to the "facebook-iphone-sdk/src" directory.
  7. While you are in Project Settings, go to "Other Linker Flags" under the "Linker" section, and add "-ObjC" and "-all_load" to the list of flags.
  8. You're ready to go. Just #import "FBConnect/FBConnect.h" anywhere you want to use FBConnect classes in your project.
  9. Working with Sessions

    The central object of FBConnect is the FBSession object. These objects represent the session of a user who has authenticated with your Facebook application. You should create only one session object at a time, and retain it for the lifetime of your application.
    To create a session, you need to use your Facebook application's API key and secret:
    session = [FBSession sessionForApplication:myApiKey secret:myApiSecret delegate:self];
    If you do not want to store your API secret in the application, you can use another method which allows you to specify a URL instead which will be called to create a session:
    session = [FBSession sessionForApplication:myApiKey getSessionProxy:myURL delegate:self];
    This URL will be called with an HTTP GET request that includes an "auth_token" argument. You may use that token to call facebook.auth.getSession on your own servers. The response that your getSessionProxy should return is the same XML response that facebook.auth.getSession returned to your server.