Extension:Facebook/Open Graph

From MediaWiki.org
Jump to navigation Jump to search

This article describes a feature in the Facebook Open Graph extension that is currently under development. If you wish to try this out, check out the opengraph branch on GitHub.

Open Graph social integration[edit]

This extension also allows you to define custom Open Graph objects. Custom objects allow your wiki to more deeply integrate into the social graph. For example, let's say the Star Wars wiki registered the "spaceship" object on Facebook and included the tag <opengraph type="spaceship"/> on the Millennium Falcon page (http://starwars.wikia.com/wiki/Millennium_Falcon). Now, in the Open Graph, this url represents a spaceship instead of an article.

Custom actions allow your users to interact with objects in creative and meaningful ways. In the example above, let's say the Star Wars wiki defines the "drive" action in the Open Graph Dashboard and connects it to the spaceship and landspeeder objects, and then specifies the relationship in LocalSettings.php:

$wgFbOpenGraphCustomActions['drive'] => array('spaceship', 'landspeeder');

When this action-object connection is made, the user's private activity log (and maybe their friends' new feeds) will say "User drove the Millennium Falcon," with a link to the wiki page. Assuming you define some Aggregations, a Timeline View for your app will be visible at the top of the user's Timeline. When sufficient connects are made, the user's Timeline will feature a Report showcasing their interactions with your app.

Custom actions[edit]

The <opengraph> tag is used to define custom objects and actions. To set up the extension, you must first define your action-object connections in your Facebook application's Open Graph Dashboard and then register them with the $wgFbOpenGraphCustomActions parameter:

// Again, check the Object Debugger on Special:Connect/Debug for any problems. 
$wgFbOpenGraphCustomActions = array(
    'drive' => array('spaceship', 'landspeeder'),
    'want'  => array('*'), // Match all custom (non-article and non-image) objects by using '*'

Actions can be placed in your wiki using the <opengraph> tag: <opengraph action="drive">Drive the {{PAGENAME}}!</opengraph>. This will render a link that, when clicked, adds the activity to the user's Timeline.

Advanced Open Graph integration[edit]

The <opengraph> tag is used for social markup and rendering action buttons. There are five properties inherent to all articles and custom objects: type, title, locale, image, and description. These properties are set automatically, but can be overriden:

<opengraph title="{{PAGENAME}}" image="[[File:image.jpg|250px]]"
    description="Verily, this vichyssoise of verbiage veers most verbose..." />

Custom objects defined in the Open Graph Dashboard can use additional properties, if any have been defined.

<opengraph type="spaceship" pilot="Han Solo" />

If the action attribute is specified, the text inside the tag will be parsed and used as a link for initiating the custom action. An object's definition and an action link can be combined using the same tag. Note that you must first register the action connected to the object and define the relationship using $wgFbOpenGraphCustomActions.

<opengraph type="spaceship" pilot="Han Solo" action="drive">Drive the {{PAGENAME}}!</opengraph>

Custom objects can be integrated into most wikis with very little effort. If your wiki uses infoboxes or other categorical templates, include the <opengraph> tag in the template.

Page: [[Millennium Falcon]]

|name=Millennium Falcon
|model=Modified YT-1300 light freighter
|pilot=Han Solo
Page: [[Template:spaceship_infobox]]
<includeonly><opengraph type="spaceship" title="{{{name|}}}" image="{{{image|}}}" /></includeonly>


If your wiki monetizes advertising, action specs can be used in ad targeting to reach out to people based on their actions. For more information see: https://developers.facebook.com/docs/reference/ads-api/action-specs-custom/