Created
September 30, 2011 08:39
-
-
Save hubgit/1253120 to your computer and use it in GitHub Desktop.
Open Graph Action example. From https://developers.facebook.com/docs/beta/samples/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/example#"> | |
<meta property="fb:app_id" content="YOUR_APP_ID" /> | |
<meta property="og:url" content="http://example.vom/cookie.html"> | |
<meta property="og:type" content="example:recipe" /> | |
<meta property="og:title" content="Oreo Stuffed Cookies" /> | |
<meta property="og:image" content="http://example.com/cookie.jpg" /> | |
<meta property="og:description" content="The Turducken of Cookies" /> | |
</head> | |
<body> | |
<!-- Facebook init --> | |
<div id="fb-root"></div> | |
<script src="http://connect.facebook.net/en_US/all.js"></script> | |
<script> | |
FB.init({ | |
appId:'YOUR_APP_ID', cookie:true, | |
status:true, xfbml:true, oauth:true | |
}); | |
</script> | |
<!-- Add to Timeline button --> | |
<fb:add-to-timeline></fb:add-to-timeline> | |
<!-- Actual page content --> | |
<h3>Stuffed Cookies</h3> | |
<p><img title="Oreo Stuffed Cookies" src="http://example.com/cookie.jpg" width="550"/></p> | |
<!-- Action button --> | |
<form onsubmit="postCook()"> | |
<input type="submit" value="Cook"> | |
</form> | |
<script type="text/javascript"> | |
function postCook(){ | |
FB.api('/me/example:cook&recipe=http://example.com/cookie.html','post', function(response) { | |
if (!response || response.error) { | |
alert('Error occured'); | |
} else { | |
alert('Post was successful! Action ID: ' + response.id); | |
} | |
}); | |
} | |
</script> | |
<!-- Recent Activity --> | |
<fb:activity actions="YOUR_NAMESPACE:cook"></fb:activity> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment