Facebook lets you post rich, structured stories from your app using a strongly typed API consisting of objects and actions. Objects are the "nouns" or targets for actions taken by people in your app.
Objects are defined by Open Graph HTML markup on web pages.
Objects are created by adding Open Graph meta tags to the page where your content is hosted.
These are the basic tags required for turning your page into an object.
Add them to the <head>
of your page's HTML.
<meta property="fb:app_id" content="1234567890" /> <meta property="og:type" content="article" /> <meta property="og:url" content="http://newsblog.org/news/136756249803614" /> <meta property="og:title" content="Introducing our New Site" /> <meta property="og:image" content="https://scontent-sea1-1.xx.fbcdn.net/hphotos-xap1/t39.2178-6/851565_496755187057665_544240989_n.jpg" /> <meta property="og:description" content="http://samples.ogp.me/390580850990722" />
In some hosting and development platforms where you create an object page and publish the object to Open Graph simultaneously, you may get an error saying that the object does not exist. This is due to a race condition that exists in some systems. We recommend that you either verify that the object page is created before you publish an action to Open Graph or introduce a small delay to account for replication lag (e.g, 15-30 seconds).
You can test your markup by passing a URL through the Sharing Debugger. This will show the tags the crawler scraped as well as any errors or warnings.
The Facebook crawler will re-scrape (and therefore update) objects:
This Graph API endpoint is simply a call to:
POST /?id={object-instance-id or object-url}&scrape=true
The response from this endpoint will be a JSON object that contains all the information about the object that was scraped (the same data returned when the Object ID is read from the Graph API).
The id
parameter can be either the canonical URL of your object or the ID of the object instance in the graph.
You can always edit an object's properties, with two exceptions:
If you want to update an image for an object, we strongly suggest that the URL to the image be different than the original image URL. Caching may prevent the image from being updated.
If you move a page to a new URL, you can use the old URL as the canonical source for the new URL, retaining likes, comments and shares for the object. Learn how in our guide to sharing for webmasters.