Developing Facebook Application

20

Click here to load reader

description

This tutorial illustrates how to set up a new Facebook application and also have some sample codes to start using Graph API and FQL

Transcript of Developing Facebook Application

Page 1: Developing Facebook Application

Developing Facebook Application

Wasu KhaodeeKanda Runapongsa Saikaew

Computer Engineering Khon Kaen University

Page 2: Developing Facebook Application

Facebook Application Types1. 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

Page 3: Developing Facebook Application

Focused Facebook APIs

1. Graph APIThe 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 sizeHas similar syntax with SQL but there are somethings that cannot be done in FQL such as

No Group by

Page 4: Developing Facebook Application

What is Graph API?

At Facebook's core is the social graph; people and the connections they have to everything they care aboutThe 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

Page 5: Developing Facebook Application

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 callYou 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.ExampleSELECT name FROM user WHERE uid = me()

Page 6: Developing Facebook Application

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

Page 7: Developing Facebook Application

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.

Page 8: Developing Facebook Application

Creating Your Canvas App (1/4)

First goto : http://www.facebook.com/developers/

here

Page 9: Developing Facebook Application

Creating Your Canvas App (2/4)

Your Apps Name here

And read the Termsthen create the app

Page 10: Developing Facebook Application

Apps URL

host URL

Creating Your Canvas App (3/4)

Page 11: Developing Facebook Application

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

Page 12: Developing Facebook Application

Create App Instance

get the SDK here : facebook.php

or download here : https://github.com/facebook/php-sdk/archives/master

Page 13: Developing Facebook Application

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

Page 14: Developing Facebook Application

Using Graph API to See Feed

Result for the code above

Page 15: Developing Facebook Application

Using Graph API to Post Status

destination user id

to post

identification of the author

the message

and this is the result

Page 16: Developing Facebook Application

Using FQL to See Picture URL

FQL command is like SQL such as SELECT, FROM, WHERE, IN or LIMIT

and this is the result

Page 17: Developing Facebook Application

Using Javascript with PHP to save ID of a specified friend name

//Get current session

//Do some FQL call

Page 18: Developing Facebook Application

Using JavaScript with PHP to post message to a friend's wall

//Send message with Graph API

Current UI

Page 19: Developing Facebook Application

Result from posting message to a friend's wall

result from the program

Page 20: Developing Facebook Application

Reference

http://developers.facebook.com/docs/http://www.slideshare.net/csaila/fql-overviewhttp://www.takwing.idv.hk/Sample Code