Facebook’s Open Graph is a ‘structured, strongly-typed API’ that let’s your users go a step beyond a Like or share.
Open Graph (OG) allows users to form a Story from actions that they take around Objects.
The OG API packages up Actions and Objects into posts that read like a personal account of an experience.
Open Graph brings a conversational tone to the staccato chatter of Likes and shares.
This article is a quick start for people who want hands on information about OG but it is not intended to be a comprehensive guide, FB has lots of those ready when you are.
What Makes Up an OG Story
Stories are made up of Actions and Objects tethered together by the App that the story was spawned from.
Open Graph Standard Action Types
Facebook has established standard Action types and groups of related Actions. They cover most anything but if they don’t cover what you need keep reading, we go over custom Actions types further down.
Testing with a Standard Action Type
Use the Graph API Explorer to easily test all of the standard Action types. Begin by creating a basic test App to use.
Be sure the set the necessary rights for a given Action when grabbing the token. For example, if the Action is Post then the rights will require Publish_Actions rights.
Browse the ID returned from your test to see the Story components.
Creating a Custom Action
Creating a custom Action is easiest via the New Story option.
The New Story wizard allows you to use existing Actions, make a new one on the fly and select the corresponding Object type easily.
After creating the Action and Object in the wizard look in the Stories panel for the Get Code option.
This option will give you the Object code (to be embedded in the <head> of the HTML) and the URL POST action to make the FB OG API post.
The OG meta properties are critical to the Custom Action working properly.
It can be helpful to debug your Object page to be sure that all of the OG meta properties are in place.
Custom Action Weirdness
Custom Actions are tricky to debug prior to approval.
There is a known FB API bug that prevents custom actions from committing to a user’s feed, even if you are using a test user.
Do not despair, if you try to test and get a “Try your request again later. OAuthException Code 2” response then you are encountering the bug the prevents Custom Actions from being committed before the App is approved!
You can see this link for more info on the bug.
To get around this test your Custom Action using the GraphAPI and you will instantly see a proper ID for the Story returned.
OG Auth From the User Perspective
Giving OG permissions is painless for the user.
FB handles the opening and closing of the user permissions dialogue as well as all content in the window.
Good luck with your Open Graph adventures and remember, don’t get discouraged by the OAuthException, just test with the GraphAPI explorer and submit your app for approval.
Author: Carol Glennon