We design and develop great software for mobile and web.
Facebook for Android API
Android talks #6 Željko Plesac
Scope• Introduction
• Prerequisites
• Common Facebook API actions
• Graph API, custom stories, Facebook Insights
• Conclusion
1. Introduction
• Facebook is the world’s largest social network, with more than 1 000 000 000 users
1. Introduction
• Facebook is the world’s largest social network, with more than 1 000 000 000 users
Facebook is the world’s largest repository of personal information!
Why use Facebook?• obtain information about users
• use it as authentication system
• export information from our applications to Facebook
• attract new users
Why use Facebook?• obtain information about users
• use it as authentication system
• export information from our applications to Facebook
• attract new users
Everybody and everything !is on Facebook!
Prerequisites
• Facebook account
• Facebook for Android SDK - current version is 3.15.0 (officially not on Maven)
• applications have to be registered on Facebook (http://developers.facebook.com) and we need to provide some basic info
Common Facebook actions
• 1. Facebook login
• 2. Post to wall
• 3. Read user data
Facebook Login
• Applications must implement Facebook Login
• OAuth 2.0.
• session management
• obtain default permissions
Permissions???
Permissions• due to the personal nature of user informations,
Facebook has developed complex schema for accessing personal data
• informations are categorised; in order to access them, you need to obtain permissions from their owners (users)
• permissions can be requested at any time
• by default, with login you obtain 3 permissions: email, public_profile, user_friends
Post to wall
• we want to export informations from our application to users Facebook wall (write comment, upload pictures, share links…)
This should be easy…
Post to wall
• 3 cases
• with Facebook native application
• with WebDialog
• with background request by using Graph API
Post to wall - case 1.• only possible if user has installed Facebook for
Android application
• check:
Post to wall - case 1.
• 2 dialogs: ShareDialog and PhotoShareDialog
• no additional permissions are needed
• user has to manually confirm publish action
Post to wall - case 2.
• If Facebook for Android application is not present on mobile device, we can use WebDialog
• no additional permissions are needed
• user has to manually confirm publish action
Post to wall - case 3.
• Applications can post automatically to users wall by using Graph API requests (not visible to user)
• in order to use this feature, app has to be submitted for Facebook review
Facebook review???
Facebook review• In order to use advanced features of Facebook, like
background write to wall, custom stories, etc… applications have to be submitted for Facebook review
• Applications have to comply with Facebook Terms
• All platforms are submitted to review
• Every feature has to be reviewed
• Upload photos - users must take these photos with an actual camera. All photos must be original
• Tags - all tags must be manually added by user
• User messages - users must personally write these messages. Even if users can control (edit or delete) the message content, applications cannot pre-fill user messages
• Applications must use the latest versions of SDK
• Applications must implement Facebook login
Example of terms
Review survival cheat sheet• all banners, icons and screenshots have to be in exact dimensions
• banners need to contain app name
• check for grammar errors
• provide real app data
• remove all unnecessary restrictions from your app
• don’t cheat - Facebook could disable your account and blacklist your application
Graph API• primary way for apps to read and write to the Facebook social graph
• social graph a representation of the information on Facebook composed of:
• nodes (basically "things" such as a User, a Photo, a Page, a Comment)
• edges (the connections between those "things", such as a Page's Photos, or a Photo's Comments)
• fields (info about those "things", such as the birthday of a User, or the name of a Page).
• HTTP based
• be sure to ask users for permissions!
OpenGraph stories• People use stories
to share the things they're doing, the people they're doing them with and the places where they happen.
Graph stories• Every story has 4 elements:
• Actor - person who published the story(i.e. Brie Taylor)
• App - app that publishes the story on the actor’s behalf (i.e. “Goodreads”)
• Action - activity the actor performs (i.e. “finished reading”)
• object - object the actor interacts with (i.e. book “Ask the Dusk”)
Common actions• Set of predefined actions, i.e.
• read a book
• listen to music
• watched the video
• they don’t need to be created, you can just start publishing them
• more at https://developers.facebook.com/docs/reference/opengraph/
Custom stories
• Open graph stories created solely for our application
• have to comply with Facebook terms
• must be reviewed on test user before they can be used in production
Custom stories
Custom story code snippet
Facebook Insights
• for collecting analytics
• data are collected anonymously
• can be shared with other Facebook users
Facebook Insights - example
Conclusion
• Facebook can greatly increase user experience of your application
• it’s not something that will be implemented in 15 minutes
• integrate Facebook at the beginning of development process due to various reviews