Authors :
Dave Bauer (dave@solutiongrove.com)
Hamilton Chua (ham@solutiongrove.com)
Last Updated : 1/29/08
Version : 0.2d
The OpenACS Facebook Helper API package adds a layer of abstraction to the Facebook API to make it easier for OpenACS developers to write facebook applications using OpenACS.
The package is meant to be a service package and should not need to be mounted anywhere.
You will need to create a separate package to become your facebook application and use the TCL Api provided by the facebook helper api package.
Before attempting to create your facebook app we advise you to visit http://developer.facebook.com for a better understanding of how Facebook's api works.
In particular, the following links will be most helpful :
This helper api communicates with Facebook thru REST.
Under the assumption that you already have the following :
ad_page_contract {
A simple page that returns a list of friends in JSON format
} -query {
{fb_sig_in_canvas ""}
{fb_sig_added ""}
{fb_sig_time ""}
{fb_sig_user ""}
{fb_sig_api_key ""}
{fb_sig ""}
{fb_sig_friends ""}
{fb_sig_session_key ""}
{fb_session_expires ""}
{fb_sig_profile_update_time ""}
{installed ""}
{auth_token ""}
{sent ""}
}
# check that we are passed an auth_token
# an auth_token allows us to get a session_key from facebook
# if auth_token is empty, it is most likely that we already have a
# session_key in fb_sig_session_key
if {$auth_token ne ""} {
set session_info [facebook_api::get_session_from_token -package_key $package_key -auth_token $auth_token -url $app_url]
set fb_sig_session_key [lindex $session_info 0]
set fb_sig_user [lindex $session_info 1]
}
# check that we have an fb_sig_session_key
# if we don't have this parameter it means that
# the user didn't get here from facebook
# but rather directly
# ask the user to login or add the app
if { [exists_and_not_null fb_sig_session_key] } {
set friends_info_json [facebook_api::get_friends_info -package_key "your_package_key" -session_key $fb_sig_session_key]
ns_return 200 "text/html" $friends_info_json
} else {
ad_returnredirect "http://www.facebook.com/add.php?api_key=$fb_sig_api_key"
ad_script_abort
}
As of version 0.2d, the facebook api package has procs that allow you to do the following ....
For more information about authenticating with facebook refer to this page.
The facebook api package now has two new tables :
Authenticating with facebook is useful if you want to run a web application outside of the facebook user interface but still have access to data from facebook.