I am planning to write a series of posts on Managing Social Media Contents from Sitecore/Sitecore – Social Media Integration and this is the first of the series.
Social Media plays an integral part of Digital Marketing. Contents posted on a Facebook page is created from different sources. Although these contents have different origins, they are shared across Facebook, Twitter or any other social media.
These posts most probably contains links to our Website pages about our products/services. When I say different origins I meant that it also includes the CMSs where these pages are created in the first place.
Now in terms of CMS, once a particular page is created by the digital marketers, these links are shared across different pages/ twitter handles. Usually each organization would have their own Facebook Pages or Twitter Handles etc as a Social Media front. The admin/Editor of these pages share these links in those mediums by logging in to these Accounts.
Analytics details of these posts/tweets like interactions and how these posts are performing is important. The performance of these posts are decided my multiple factors and one of the undeniable parameter is the Content of this post – in simple terms, the post’s captions/Images. (Which is again a Content to us)
“Although we have Facebook Analytics, Twitter analytics to provide us that info, I personally felt that it creates a tiny separation between a Page and a Facebook Post even if the post is about the same page and I feel that it should be considered as a single entity.“
When thinking about this deeper, what better place to manage those social media contents (Posts/Tweets) than it’s origin – CMS (which Sitecore in our case.)
Although I wanted to share a wide, more complete solution, I’m afraid whether I would be able to make time for doing it in near future hence this first part.
When I say wide, we can use Graph/Insights API and Twitter Analytics API and create a Sitecore SPEAK application probably with graphs and tables as stats to show how each post associated with a Sitecore page is performing in different Social Media.
But as I said for now, I was able to make the first step alone. Hoping to work on this more and share the complete solution.
All the above paragraphs were meant to give you the answer for why this post.
Now coming back to the title, In this post, I am sharing my experience on creating a custom sitecore command that allows you to post a Sitecore page as Facebook Post from Sitecore Content Editor.
Of course this would require some stuffs like a Facebook Page, it’s admin credentials, Authorization token.
We’ll be using Facebook’s Graph API for posting to your Facebook Page.
Once, the APIs, Tokens are setup, we would be using a similar logic like Create Custom Compress Command and create a Custom Command named Publish to Facebook.
Getting to know about Graph API:
- Login to https://developers.facebook.com and create an App. We will be making use of this app to post to Facebook via Sitecore.
- Facebook has a decent documentation on it’s Graph API that is more than enough for us to get started.
- You can access the documentation here
- Once the App is created make note of it’s ID (APP ID) and Secret Key (APP Secret)
- Add Login product, setup page access token for the app for managing/publishing contents to the page.
- For the time being I made use of Permanent Access Token, but for higher environment, this is not recommended and it is best practice to make use of Facebook’s OAuth 2.0 authentication. https://graph.facebook.com/{page-id}/feed?message=Hello_Fans!&access_token={page-access-token}
- This is the API we will be using for posting the page content to Facebook.
- For getting the access token, please refer.
Publish to Facebook Command
- I wouldn’t be walking through on the steps to create a custom command. For more details on this as already mentioned above refer this post.
- Here, I have made use of SEO Fields of a Page item and added them as Post captions. Of course we can create a separate field names Facebook Caption and make use of it.
- After adding the necessary menu items in Core DB, the corresponding class and creating the corresponding config patches,






Similar to this we can create a Publish to Twitter command and make use of Twitter API to post it on corresponding twitter handle.