Alphageeks meetup - facebook api

  • Published on
    05-Dec-2014

  • View
    886

  • Download
    1

DESCRIPTION

By Liran Zelkha

Transcript

JBOSS5Facebook and OpenSocial Development " Liran.zelkha@alunasoft.com1AlunaIsraels leading Java/JavaEE and SOA consulting companyCustomers:2How 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.3Facebook Communicationuserfacebook.comapplication (UCT)request for profileprofilerequest for canvascanvasFacebook API useupdate profile box, etc.request for canvas contentcanvas4What 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.5Client LibrariesClient libraries will simplify the calls to the platform by reducing the amount of code you have to write.If you dont use a client library then will have to do the following for each method call:Construct a signatureCreate and send a HTTP POST requestParse the XML result of the request6Example ClientsFacebook ClientsPHP5JavaIndependent ClientsActionScriptCocoaPHP4RubyPythonVB.NET7MethodsThe facebook API currently has 20 methods that can be used to get information from facebook accounts.8Authenticationfacebook.auth.createTokencreates an auth_token to be passed in as a parameter to login.phpfacebook.auth.getSessionreturns the session key bound to an auth_token9Facebook Query LanguageFacebook.fql.queryFQL 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 10Eventsfacebook.events.getreturns all visible events according to the filters specifiedfacebook.events.getMembersreturns membership list data associated with an event11Friendsfacebook.friends.areFriendsreturns whether or not each pair of specified users is friends with each otherfacebook.friends.getreturns the identifiers of the current users Facebook friendsfacebook.friends.getAppUsersreturns the identifiers of the current users Facebook friends who are currently signed in12Groupsfacebook.groups.getreturns all visible groups according to the filters specifiedfacebook.groups.getMembersreturns membership list data associated with a group13Notificationsfacebook.notifications.getreturns information on outstanding Facebook notifications for current session user.such as messages, friend requests, pokes, group invites and event invites14Photosfacebook.photos.addTagadds a tag with the given information to a photofacebook.photos.createAlbumcreates and returns a new album owned by the current session userfacebook.photos.getreturns all visible photos according to the filters specified15Photosfacebook.photos.getAlbumsreturns metadata about all of the photo albums uploaded by the specified userfacebook.photos.getTagsreturns the set of user tags on all photos specifiedfacebook.photos.uploaduploads a photo owned by the current session user and returns the new photo16Usersfacebook.users.getInforeturns the information in a users profilefacebook.users.getLoggedInUsergets the user id associated with the current session17ResponsesEach of these methods can have a different response format depending on what you are programming in.JSON (JavaScript Object Notation) XMLFacebook PHP Client18FBMLLanguage 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 for a users name for a users profile picture19FQLFacebook 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-id20Creating an ApplicationWhat you need:Web ServerAPI toolkit or roll-your-ownAdd the Developer application to your profile.Switch to the Developer application.Apply for a key.2122232425What 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.26Example: Profile Box27Example: Application Canvas28Open Social29What problem does it try to solve?Writing applications specifically for a single API3031Why?DevelopersCan reuse apps on new social networks Reduce code maintenanceIncreased potential audience for applicationSite OwnersNew site immediately gains many applicationsPre-existing broad developer base32Who Does It?3334