The Facebook API Menagerie
Facebook API has many different parts:
Canvas Apps
FB requests from your site, they inline the resonse in the middle of the page.
- Not available: JavaScript.
- Available: FBJS – a sandboxed limited JS API, FBML – a templating language, the FB session.
iFrame Apps
Your response is put in an IFRAME on the page.
- Available: FB session.
- Not available: FBJS, FBML.
Connect App
Host your app on your own domain.
Connect back into FB to e.g. user their authentication & friends model.
- Available: Connect Session
- Not available: FB Session
Pages/Profiles
- No JS
Think of FB as a browser
FB API LOLZ
- REST API – api/facebook.com/restserver.php – awesome URL.
- Facebook does not do GETs, they always POST to your site.
- Connect inside an iFrame, Connect requires the XHTML doctype to work, but iFrames are not supported in XHTML.
SRSLY
Running your App in development
- Create an app
- Setup DynDNS.com, point it at your IP address http://mysubdomain.dyndns.com
- open ports on your local network
- Add /etc/host entry: 0.0.0.0 facebook.dontexist.com
Abstract the API
- Use Facebooker.
- apps.facebook.com/facebooker_tutorial
- Access everything through the session
if session[:facebook_session]
@friends = session[:facebook_session].user.friends.collect do |f|
User.find_by_fb_user_id f.uid
end
Project your code
e.g. use rack-facebook so everything is not a POST
Others
- Frakie: Facebooker for Sinatra
- rack-facebook: tranlates FB POST to correct action
How can I make things better?
- Need a test harness for session[:facebook_session]. There is something in facebooker that needs extraction.
- Greg is starting Faceboot API Continouus Integration Suite of Tests – github.com/atduskgreg/FACIST – some JS hooks to green/red light that your tags are actually showing up in the page.
About the Author