raffael / RMFBLayer

Facebook API access for Mac applications, that uses OS X FB integration if available, otherwise PhFacebook.framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RMFBLayer

RMFBLayer is a class to access the Facebook API within OS X applications by sending requests either using the OS X Facebook integration (if available) or PhFacebook.framework as fallback.

OS X Facebook integration (Social.framework) might not be available due to the fact that the user has not updated yet to OS X 10.8.2 or that the user has not set up the Facebook account in his System Preferences. The RMFBLayer automatically recognizes these circumstances and uses then PhFacebook.framework instead.

RMFBLayer provides a streamlined interface to the two Facebook API abstractions to facilitate the data retrieval. All requests are based on the completion block paradigm.

WARNING: Since PhFacebook.framework originally does not support completion blocks, a modified version is available as fork, separately.

Requirements:

  • You have added Social.framework to your app
  • You have added the PhFacebook.framework with completion block support

Details:

RMFBLayer provides an interface to quickly send requests and process their result. It does that by delegating the requests to abstractions. Currently, two abstraction intances are available:

  • RMFBOSX: The OS X Facebook integration,
  • RMFBPhFacebook: The PhFacebook framework Both abstractions, and the layer itself, share the same interface to access the Facebook API.

To make FQL requests, wrap them into a normal GET request.

Usage:

  1. Set the preferred abstraction and add the two abstractions:
	[[RMFBLayer sharedInstance] setPreferredFramework:RMFBFrameworkOSX];
	[[RMFBLayer sharedInstance] addAbstraction:[[RMFBOSX alloc] initWithFacebookAppId:kFacebookAppId]];
	[[RMFBLayer sharedInstance] addAbstraction:[[RMFBPhFacebook alloc] initWithFacebookAppId:kFacebookAppId]];
  1. Set the delegate in order to be notified once the auth has finished:
	[[RMFBLayer sharedInstance] setDelegate:self];
  1. Start the authentication:
	[[RMFBLayer sharedInstance] authForPermissions:@[@"read_mailbox"]];
  1. Make a new request:
	[[RMFBLayer sharedInstance] performGETRequest:@"/me" usingParameters:@{
		@"fields": @"id"
	} andCompletionHandler:^(NSObject *resultObject, NSError *error) {
		NSLog(@"Get request result: %@", resultObject);
		NSLog(@"Get request error: %@", error);
		NSString *identifier = [((NSDictionary *)resultObject) objectForKey:@"id"];
	}];

Status

Currently marked as BETA. PhFacebook usage has not been tested heavily.

Contact

License

Copyright (c) 2013 Raffael Hannemann Under BSD License.

Want more?

Follow @raffael_me for similar releases.

About

Facebook API access for Mac applications, that uses OS X FB integration if available, otherwise PhFacebook.framework


Languages

Language:Objective-C 100.0%