This is a quick start guide to get you up and running w/ FQL part of the Facebook API.
Say for example: We want to get all the videos of a user (myself in this case) - we first need to get the user’s permission to access their information. Facebook handles authentication via the oath protocol. The flow would like this:
- User clicks link to install your app and clicks yes
- Response sends oath token so you can access their data.
Before anything else you need to first register you app and get it’s app id.
Get OAuth Token
Now for step #1 in the flow send the user the below link - it’s the standard FB app yes/no page we’ve all seen:
https://www.facebook.com/dialog/oauth? client_id=164837516907837& type=user_agent& scope=email,read_stream,user_videos,friends_videos,user_about_me,offline_access& redirect_uri=http://www.facebook.com/connect/login_success.html
- client_id is the app_id you get after registartion w/ fb
- type=user_agent is telling facebook this is a desktop app as opposed to a web app (in a browser) (this is oath feature - the type param)
- scope is the permissions your app is requesting. If you don't add offline_access your token will expire after about an hour - offline_acess lets it last forever!
- redirect_uri is the page where the user is taken after they click OK. The above is a special URL that FB allows for desktop apps. If it was a webapp it would redirect to a real page for the user to see.
After the user clicks OK they are redirect to the redirect_url and the oath toaken is in the response URL.
After this you’ll get your oath token!!!
Now you can query that user’s graph:
and use FQL queries
https://api.facebook.com/method/fql.query?query=SELECT vid, owner, title, description, thumbnail_link, embed_html, updated_time, created_time FROM video WHERE owner=13772156826&access_token=164837516907837|2.2gdLzMH6jVTBP2g8sr604g__.3600.1302642000-674426473|c5sHb3xK-zCvdmdOb2vzeiov7Yo
That will get all videos of given user in XML.
Tags: facebook api social graph fql