Alphageeks meetup - facebook api

34
Facebook and OpenSocial Development הההה ההההה ההה"ה ההההה[email protected]

description

By Liran Zelkha

Transcript of Alphageeks meetup - facebook api

Page 1: Alphageeks meetup - facebook api

Facebook and OpenSocial

Development

לירן זילכהמנכ"ל משותף

[email protected]

Page 2: Alphageeks meetup - facebook api

AlunaIsrael’s leading Java/JavaEE and SOA

consulting companyCustomers:

Page 3: Alphageeks meetup - facebook api

How Facebook Apps workEvery profile page is made up of many

independent portlets or profile boxes.Each portlet is generated statically by a possibly

external application and stored by Facebook.It could be an iframe, but in most cases is not.Portlets are not actually changed in the profile

page – they are changed elsewhere!Facebook has mechanisms to link in applications,

and APIs for applications to communicate with Facebook.

Page 4: Alphageeks meetup - facebook api

Facebook Communication

user facebook.com application (UCT)

request for profile

profile

request for canvas

canvas

Facebook API use

update profile box, etc.

request for canvas content

canvas

Page 5: Alphageeks meetup - facebook api

What can the API doGet a list of friend ids or friends who are

running the same appGet and set notifications of eventsSet content of profile boxGet specific information on a userAdd to the Newsfeed for a userEtc.

Page 6: Alphageeks meetup - facebook api

Client LibrariesClient libraries will simplify the calls to the

platform by reducing the amount of code you have to write.

If you don’t use a client library then will have to do the following for each method

call:◦Construct a signature◦Create and send a HTTP POST request◦Parse the XML result of the request

Page 7: Alphageeks meetup - facebook api

Example ClientsFacebook Clients

◦PHP5◦Java

Independent Clients◦ActionScript◦Cocoa◦PHP4◦Ruby◦Python◦VB.NET

Page 8: Alphageeks meetup - facebook api

MethodsThe facebook API currently has 20

methods that can be used to get information from facebook accounts.

Page 9: Alphageeks meetup - facebook api

Authenticationfacebook.auth.createToken

◦creates an auth_token to be passed in as a parameter to login.php

facebook.auth.getSession◦returns the session key bound to an auth_token

Page 10: Alphageeks meetup - facebook api

Facebook Query LanguageFacebook.fql.query

◦FQL is a way to query the same facebook data you can access through the other API functions,

but with a SQL style interface.

◦SELECT name, affiliations FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE

uid1=211031) AND "Facebook" IN affiliations.name AND uid < 10

Page 11: Alphageeks meetup - facebook api

Eventsfacebook.events.get

◦returns all visible events according to the filters specified

facebook.events.getMembers◦returns membership list data associated with

an event

Page 12: Alphageeks meetup - facebook api

Friendsfacebook.friends.areFriends

◦returns whether or not each pair of specified users is friends with each other

facebook.friends.get◦returns the identifiers of the current user’s

Facebook friendsfacebook.friends.getAppUsers

◦returns the identifiers of the current user’s Facebook friends who are currently signed in

Page 13: Alphageeks meetup - facebook api

Groupsfacebook.groups.get

◦returns all visible groups according to the filters specified

facebook.groups.getMembers◦returns membership list data associated with a

group

Page 14: Alphageeks meetup - facebook api

Notificationsfacebook.notifications.get

◦returns information on outstanding Facebook notifications for current session user.

◦such as messages, friend requests, pokes, group invites and event invites

Page 15: Alphageeks meetup - facebook api

Photosfacebook.photos.addTag

◦adds a tag with the given information to a photo

facebook.photos.createAlbum◦creates and returns a new album owned by the

current session userfacebook.photos.get

◦returns all visible photos according to the filters specified

Page 16: Alphageeks meetup - facebook api

Photosfacebook.photos.getAlbums

◦returns metadata about all of the photo albums uploaded by the specified user

facebook.photos.getTags◦returns the set of user tags on all photos

specifiedfacebook.photos.upload

◦uploads a photo owned by the current session user and returns the new photo

Page 17: Alphageeks meetup - facebook api

Usersfacebook.users.getInfo

◦returns the information in a users profilefacebook.users.getLoggedInUser

◦gets the user id associated with the current session

Page 18: Alphageeks meetup - facebook api

ResponsesEach of these methods can have a

different response format depending on what you are programming in.

◦JSON (JavaScript Object Notation) ◦XML◦Facebook PHP Client

Page 19: Alphageeks meetup - facebook api

FBMLLanguage used by Facebook to specify

any fragment of Web pages.Mostly just like HTML!Forms get additional fields added to pass

Facebook parameters silently.Images are redirected to local copies.Links must be absolute (parameters do

not work as expected in all toolkits).Lots of additional Facebook-specific items

◦<fb:name uid=…> for a user’s name◦<fb:profile-pic …> for a user’s profile picture

Page 20: Alphageeks meetup - facebook api

FQLFacebook Query Language allows access

to user database with language that is similar to SQL.

Example:◦SELECT first_name FROM user WHERE

uid=$params->{user}◦To get the first name of a user based on the

user-id

Page 21: Alphageeks meetup - facebook api

Creating an ApplicationWhat you need:

◦Web Server◦API toolkit or roll-your-own

Add the Developer application to your profile.

Switch to the Developer application.Apply for a key.

Page 22: Alphageeks meetup - facebook api
Page 23: Alphageeks meetup - facebook api
Page 24: Alphageeks meetup - facebook api
Page 25: Alphageeks meetup - facebook api
Page 26: Alphageeks meetup - facebook api

What does a typical application do?Check CGI parameters.Authenticate using Facebook API.Draw configuration Web page on canvas.Allow user to update options… Write FBML to profile box.Save per-user state in database or in

filesystem.

Page 27: Alphageeks meetup - facebook api

Example: Profile Box

Page 28: Alphageeks meetup - facebook api

Example: Application Canvas

Page 29: Alphageeks meetup - facebook api

Open Social

Page 30: Alphageeks meetup - facebook api

What problem does it try to solve?Writing applications specifically for a

single API

Page 31: Alphageeks meetup - facebook api
Page 32: Alphageeks meetup - facebook api

Why?Developers

◦Can reuse apps on new social networks ◦Reduce code maintenance◦Increased potential audience for application

Site Owners◦New site immediately gains many applications◦Pre-existing broad developer base

Page 33: Alphageeks meetup - facebook api

Who Does It?

Page 34: Alphageeks meetup - facebook api