Developing Facebook
Application
Wasu Khaodee
Kanda Runapongsa Saikaew
Computer Engineering
Khon Kaen University
Facebook Application Types
1. Run on web-browser
1.1 A Website
1.2 Canvas Application
(Apps on Facebook.com)
2. Run on a platform
- Mobile Application
In this slide, we focus on developing Canvas Application
Focused Facebook APIs
1. Graph API
• The Graph API is the core of Facebook Platform, enabling
you to read and write data to Facebook
• “nested query” is not supported by Graph API and in many
cases, we need to get the data with multiple Graph API
requests
2. FQL (Facebook Query Language)
• FQL is designed to condense Facebook queries and reduce
response size
• Has similar syntax with SQL but there are somethings that
cannot be done in FQL such as
o No Group by
What is Graph API?
• At Facebook's core is the social graph; people and the connections
they have to everything they care about
• The Graph API presents a simple, consistent view of the Facebook
social graph, uniformly representing objects in the graph
(e.g., people, photos, events, and pages) and the connections
between them (e.g., friend relationships, shared content, and photo
tags)
• Every object in the social graph has a unique ID
• You can access the properties of an object by
requesting https://graph.facebook.com/ID
What is FQL?
• Facebook Query Language, or FQL, enables you to use a SQL-style
interface to query the data exposed by the Graph API. It provides for some
advanced features not available in the Graph API, including batching
multiple queries into a single call
• You can execute FQL queries by
fetching https://api.facebook.com/method/fql.query?query=QUERY. You
can specify a response format as either XML or JSON with
the format query parameter.
• Example
• SELECT name FROM user WHERE uid = me()
Facebook Software
Development Kit (SDK)
Here we are using PHP and Java Script
- PHP SDK where source
here : https://github.com/facebook/php-sdk/
- Java Script where source
here : http://connect.facebook.net/en_US/all.js
Application Permissions
Applications Permissions
http://developers.facebook.com/docs/authentication/
permissions
Your App got only public data access without request
more permission.
Likes your app need to post some content
"publish_stream" need to be requested.
Creating Your Canvas App (1/4)
First goto : http://www.facebook.com/developers/
here
Creating Your Canvas App (2/4)
Your Apps Name here
And read the Terms
then create the app
Creating Your Canvas App (3/4)
Apps URL
host URL
Creating Your Canvas App (4/4)
For Apps URL is where user access to your app.
Like http://apps.facebook.com/fbpublishpage
And host URL is where your Code is located.
Here we choose Canvas type as IFrame according to
Developer Roadmap
Create App Instance
get the SDK here : facebook.php
or download here : https://github.com/facebook/php-
sdk/archives/master
Get Session and Login
//Get App Session
//Get User Info to check the
login status
//Get login URL (also
grants permissions)
//Just login if the user did not login
Using Graph API to See Feed
Result for the code above
Using Graph API to Post Status
destination user id identification of the author
to post the message
and this is the result
Using FQL to See Picture URL
FQL command is like SQL such as SELECT, FROM,
WHERE, IN or LIMIT
and this is the result
Using Javascript with PHP to save ID of a
specified friend name
//Get current session
//Do some FQL call
Using JavaScript with PHP to post
message to a friend's wall
//Send message with Graph API
Current UI
Result from posting message to a
friend's wall
result from the program
Reference
• http://developers.facebook.com/docs/
• http://www.slideshare.net/csaila/fql-overview
• http://www.takwing.idv.hk/
• Sample Code