Social Connected with Sitecore (Facebook) 3: Post ad hoc messages to facebook

The facebook social connected module only allows your application to post to a user timeline when a goal is triggered.

Your site business logic might need you to make ad hoc posts when certain logic is triggered. While we could definitely achieve the results we want by creating goals for each of these actions, this might not adhere with the marketing guidelines.

So here is how we achieved this functionality using the Facebook js API

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
var facebookAppId = '<%=FacebookDefaultAppId %>';
FB.init({ appId: facebookAppId, status: true, cookie: true, xfbml: true });

function openFbPopUp() {
FB.ui({
method: 'feed',
name: 'Your Site Name',
caption: ' ',
link: document.URL, // Current Url
description: $('#quotes').html(), 
// Description from the sitecore item which was available in the same page
display: 'popup'
});
return false;
}
</script>

FacebookDefaultAppId – was the app id (Application Id) set in the sitecore item where we set the facebook app details:

1hvuP

Which we get here in facebook for the app created:
7Jbdw

Truth be told, this solution has nothing to do with sitecore, but since we manage the app secret key in sitecore, I am pulling it in from there as opposed to saving it some place else too.

This results in the following when the js is triggered (say on button click):
2014-06-17_194018

Advertisements

, , ,

  1. Social Connected with Sitecore (Facebook) – Demo Video | Tech Musingz

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: