Home > Development, MacOSX > Introducing PhFacebook, a Cocoa framework to Facebook’s API

Introducing PhFacebook, a Cocoa framework to Facebook’s API

August 29th, 2010

For the upcoming version of iChibi, I needed a MacOSX interface to Facebook’s API.

There are several iOS libraries (FB Connect, ShareKit…) but I found only one that was MacOSX-specific: MBAbeFook, which implements the (deprecated) Facebook REST API.

This was a problem because:

  • I need extended permissions, and it’s a song-and-dance to get those using the REST API
  • The authentication UI from REST may present checkboxes to the user for extended permissions.
    Users don’t check boxes. They click “I agree”…
  • The REST API is deprecated.

So I wrote my own. PhFacebook is an embeddable MacOSX framework to easily access Facebook’s API.

  • Uses Facebook’s new ‘graph’ API internally, handles OAuth in a WebView for you and returns JSON strings.
  • Comes with a sample application to show you how to use it.
  • Supports extended permissions.
  • Localized in English and French.

Find it on github. MIT-licensed.

Categories: Development, MacOSX Tags:
  1. Ryan
    January 13th, 2011 at 04:51 | #1

    Hey!
    I was super happy when I found this framework! However, when I try to use your sample code I am getting 9 errors. It is not finding your framework headers. I built the framework, then dragged from the finder into the sample project…made sure it was on the target…made a direct dependency….What am I missing? Header Search Paths?

    Thanks!

  2. January 13th, 2011 at 07:03 | #2

    Try to have a common build folder. It makes things a lot easier when dealing with subprojects and frameworks.

    Xcode->Preferences->Building->Place Build Products in->Customized location

    I do that because while I can fix the search paths for one project, they will be different for other projects and it tends to not work on other people’s systems. With a common build folder, everything just works.

  3. Richard
    January 14th, 2011 at 05:45 | #3

    Tried everything I can think of (and I have this working with Facebook’s own iOS framework)

    But clicking Get Access Token doesn’t ever do anything

  4. January 15th, 2011 at 11:35 | #4

    @Richard
    Fixed in the github project. Thanks for letting me know; a better way is through github’s issue tracker interface.

  5. February 5th, 2011 at 19:49 | #5

    Hi Philippe!

    I like your framework but i have a little problem, the webview won’t show up with the loginpage.
    I have set the delegate and everything, i see the loginURL in the debug console but no webview will appear.

    Any clues? I use Xcode 4 is that does matter.

    Regards , Billy

  6. February 6th, 2011 at 09:12 | #6

    Hi Billy,

    Please open an issue on github: https://github.com/philippec/PhFacebook/issues

    That is a much better way to track down these problems.

    Thanks!

  7. Mike
    February 9th, 2011 at 14:20 | #7

    Trying to get this working… followed all the steps to the letter, but something’s breaking when I go to run. Built the framework with no problem. Drug from the Finder into my app, copied. Added to copy phase. Added the appropriate #import statement. Built MyApp with no problem. When I go to run, it fails with:

    dyld: Library not loaded: @rpath/PhFacebook.framework/Versions/A/PhFacebook
    Referenced from: /Volumes/WorkingCopies/MyApp/source/trunk/build/Debug/MyApp.app/Contents/MacOS/MyApp
    Reason: image not found

    Deleted all, started over 3 times…. same problem. What am I missing?

  8. February 10th, 2011 at 23:56 | #8

    @Mike

    Hmmm, I recently changed to @rpath. Can you open an issue on github so we can track this?

  9. dragi
    February 13th, 2011 at 06:31 | #9

    Hello,

    first of all: Thank you so much for your framework…I think it’s really great!
    Since I’m totally new to the graph API and to your framework I have one question. Is it possible to Post something with your framework?
    The API example to post something is

    curl -F ‘access_token=…’ \
    -F ‘message=Hello, Arjun. I like this new API.’ \
    https://graph.facebook.com/arjun/feed

    but I don’t know how to put this into [fb sendrequest: NSString]? Can someone give me a hint how the string has to look like? @”‘message=Test’ \ me/feed” does not work.

    Thank you

  10. February 16th, 2011 at 23:17 | #10

    I’m sure it’s possible, I just never tried. Did you add the “write” property to the request? Maybe that’s all you’re missing. The sample app only has “read”.

  11. Gustavo
    April 30th, 2011 at 03:54 | #11

    Hello

    Supper, Im trying to use it but I dunno what am I doing wrong, first I got the no image found.. but then what I did it was to jsut drag and drop the whole PhFacebook proj to my project wrokspace and it seemed to compile and run..

    I was trying the test app, I set up my add id and when I clicked get token I was asked to authorize the use of my app, but then I just saw a success word and that was it. I I was expecting other page as in the permissions are @read_stream”, @”export_stream”,

    What did I miss?

  12. April 30th, 2011 at 07:20 | #12

    @Gustavo

    Hi Gustavo,

    Please open an issue on github: https://github.com/philippec/PhFacebook/issues
    That is a much better way to track down these problems.
    Thanks!

Comments are closed.