Posting to Facebook with Sitecore Social Connect

1.1k views Asked by At

I'm using Sitecore Social Connect to log users into my website using Facebook & Twitter. Sitecore's documentation has detailed instructions on how to post to a user's timeline using Marketing Goals, but I'm wondering if there's another way to do this. Is it something I can do directly through the API? Pretty much any other options would be worth exploring. There's not a ton of documentation around this.

3

There are 3 answers

0
aceanindita On

We used the facebook js API itself to achieve this:

    <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:

enter image description here

Which we get here in facebook for the app created: enter image description here

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): enter image description here

0
Dan Solovay On

Social connected messages must be associated with either content items or marketing goals, but it is possible to trigger a marketing goal using the API:

GoalUtil.RegisterEventParameters("Goal Name", new Dictionary<string,string>());

This fires the goal, and has the additional feature of allowing you to replace tokens in the message text. For example, if you defined a Goal named "Mayor", and create an associated Facebook message with this text: "I've just become mayor of $place.", you can cause this to appear on a user's Facebook wall specific text by doing this:

var tokens = new Dictionary<string, string>();
tokens.Add("place", "New York");
GoalUtil.RegisterEventParameters("Mayor", tokens);

This message will appear on the users wall: "I've just become mayor of New York." Notice that the dollar sign appears in the message, but not in the token key value added to the dictionary. GoalUtil is in the namespace: Sitecore.Social.Core.Publishing.Utils, in the Sitecore.Social.Core.dll.


In addition, when a message is associated with a goal, the following rule is added to the goal:

where true (actions always execute)
post associated messages

You can replace the always true condition with different logic, possibly using Rules Engine conditions you have authored, to restrict messages to meet the required business logic.

0
Yuriy On

Sitecore Social Connected API was introduced in the 1.3.1 version. The API documentation is available here: http://sdn.sitecore.net/Products/Social%20Connected%20Module/Social%20Connected%201,-d-,3/Documentation.aspx