|
Project Information
Members
Featured
Downloads
Links
|
Facebook Graph APIApr 2010: Facebook introduced their new API, Graph API, which completely replaces the old REST API. This API has been rewritten to support Graph API. Downloads: http://code.google.com/p/fbas/downloads/detail?name=fbgraph20100511.zip SVN: https://fbas.googlecode.com/svn/trunk/fbgraph What is Graph APINote: please read this section Read: You gave it an url in the form of http://graph.facebook.com/{id}/{connection}, Facebook will return a dynamic object representing the data. Write: You do a http POST to an url If you chew on this for a little bit, you will see the beauty of the Graph API and the beauty of this library. By calling GraphApi read() or write() method, you have access to the entire Graph API. UsageNote: Because our OAuthUtil class uses ExternalInterface, you must set allowScriptAccess="always" or "sameDomain" Note2: Your web page need to be on https because the graph api url are in https (This no longer is the case after Facebook relax the crossdomain.xml a few months back) First, embed the following javascript code in html. The following javascript code will go through Facebook OAuth mechanism. It will redirect user to Facebook's authentication page, then Facebook will redirect user back after login is done. (If the user is already login, then it should redirect the user right back). <script>
// careful! this is for example only. we are using global namespace.
var appId = "109401095767649"; // for testing on http://localhost:8888
fbAuthorize();
function fbAuthorize() {
// get the hash
var hash = self.document.location.hash.substring(1);
if (hash.indexOf("access_token") == -1) {
var authorizeUrlTemplate = "https://graph.facebook.com/oauth/authorize?client_id=$client_id$&redirect_uri=$redirect_uri$&type=user_agent&display=popup";
var authorizeUrl = authorizeUrlTemplate.replace("$client_id$", appId);
authorizeUrl = authorizeUrl.replace("$redirect_uri$", window.location);
window.location = authorizeUrl;
} else {
// access_token exist. we can continue. (log?)
}
}
</script>Flex code: var apiUrl = "http://graph.facebook.com/me/likes"; var graphApi:GraphApi = new GraphApi(); graphApi.read(apiUrl, getFriendsCallback); ...
private function getFriendsCallback(result:FbCallbackResult):void {
if (result.success) {
for each (var likeObj:Object in result.result.data) {
var like:Like = new Like();
like.id = likeObj.id;
like.name = likeObj.name;
like.category = likeObj.category;
// do something to like object.......
}
} else {
Alert.show(result.faultEvent.fault.faultString);
}
} Below are Legacy Info:If you are a new user, ignore the old info below. Facebook made changes to their API, too often for many's likings. So we have to update the API as well. Downloads: http://code.google.com/p/fbas/downloads/list Extending Jason Crist's facebook-actionscript-api. Jason Crist's original api: http://code.google.com/p/facebook-actionscript-api To access opensocial (such as Myspace, orkut, Hi5, Netlog, Hyve, etc) through actionscript: http://code.google.com/p/opensocial-actionscript-client Bebo PortThis API library is ported to Bebo. It is not yet in the download section, but you can get the source code from svn (get Facebook.as file). It hasn't been tested much. Only one basic API call is tested for WidgetSession and one API call is tested for DesktopSession. Feel free to let me know or comment if something is broken. Quick setup
Here are the new API methods added to the original facebook-actionscript-api
Other changes
Change logs2008/08/24For widgetSession, choose different Facebook API server URL based on whether user is on new or old Facebook. Default to new Facebook. files changed: Facebook.as changes r11 2008/08/26Add new feed APIs for new facebook profile (one-line-story, short-story, and full-story templates). APIs include register, get, deactivate template-bundle, and publisherUserAction. files added: data model:
delegate:
files modified:
changes r13 2008/08/30-31notifications.send and feed.publishTemplatizedActionDelegate now takes either an array of FacebookUser or an array of uid. These two methods used to take only an array of FacebookUser as argument. Files modified: SendNotificationsDelegate PublishTemplatizedActionDelegate Backward-compatible: yes 2008/09/01Fix bug on PublishTemplatizedActionDelegate regarding image_4 parameters. Previously, image_4 parameters is mistyped as image_3 Files modified: PublishTemplatizedActionDelegate.as change r20 Backward-compatible: yes 2008/10/12 and 10/14Fix bug on photos.getTags() (GetTagsDelegate) 1. The parameter name should be "pids" instead of "photos" - without this change, getTags() will always return empty 2. handle both user tag and pure-text tag - There are 2 types of tags, user tag (the tag represents a user). pure-text tag (the tag does not represent a Facebook user, it can be any text that is entered). Files modified: GetTagsDelegate.as Backward-compatible: yes 2008/12/10uid should be Number, not int Facebook uid is 64 bits. Bebo uid is also 64 bits. Files modified: FacebookUser.as GetSessionDelegate.as change r28 Backward-compatible: yes 2008/12/16revert change made in r11. r11 allows app to distinguish between old and new profile and use different api url. Since Facebook has permanently removed old profile. So now api.facebook.com or api.new.facebook.com does the same thing. There is no need to distinguish between old and new facebook profile. Files modified: Facebook.as change r29 Backward-compatible: no 2008/12/16Port this library to Bebo. startWidgetSession() and startDesktopSession() should both work. Files modified: Facebook.as change r30 Backward-compatible: yes 2008/12/23, 2009/01/02uid should be Number, not int. (because Facebook uid can be 64bits) Files modified: GetAlbumsDelegate.as Photo.as GetFriendsDelegate.as Backward-compatible: yes 2009/01/09create new constants NETWORK_FB and NETWORK_BEBO. Files modified: Facebook.as change r37 Backward-compatible: yes |