How To Publish Actions On Timeline « Facebook

How To Publish Actions On Timeline

Step 1: visit developers.facebook.com/apps and then select your app if you have multiple apps and click on Edit open Graph in Open Graph section.

Step 2: Click on Get Code in Object Types and copy the highlighted code from popup window and save it somewhere.

Step 3: Click on Get Code in Action Types and copy the access token as shown in the below image and save it also.

Step 4: Make your own script and then, paste the codes in it.

<html xmlns=”http://www.w3.org/1999/xhtml” dir=”ltr” lang=”en-US”
xmlns:fb=”https://www.facebook.com/2008/fbml”>

Paste the code copied in step 2

<script type=”text/javascript”>
function post()
{
FB.api(‘/me/Your_Namespace:action‘ +
‘?object=site.com/script.html&access_token=Paste the access token copied in step 3‘,’post’,
function(response) {
var msg = ‘Error occured’;
if (!response || response.error) {
if (response.error) {
msg += “\n\nType: “+response.error.type+”\n\nMessage: “+response.error.message;
}
alert(msg);
}
else {
alert(‘Post was successful! Action ID: ‘ + response.id);
}
});
}
</script>

</head>

<body>
<div id=”fb-root”></div>
<script src=”http://connect.facebook.net/en_US/all.js”></script>
<script>
FB.init({
appId:’Your_appId‘, cookie:true,
status:true, xfbml:true, oauth:true
});
</script>
<form>
<input type=”button” value=”Post To Your Timeline ” onclick=”post()” />
</form>
</body>
</html>

 

Leave a Reply

Your email address will not be published. Required fields are marked *