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.

Screenshot_5_20_13_9_47_PM

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.

The parts of an Open Graph Story

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.

Standard Open Graph Action Types

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.

Test Posting an Action with the Graph API Explorer

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.

Screenshot_5_22_13_12_29_PM

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.

Debugging Objects
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.

Screenshot_6_2_13_9_29_PM

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.

Screenshot_5_20_13_9_29_PM

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


Category:
api, facebook
Tags:
, , , , , , , ,