Brian McKeiver's Blog

Automatically Post Your Content to Twitter and Facebook using Kentico CMS 7 - Part 2

In part 1 of this mini blog post series we setup a Twitter App that eventually we will connect Kentico CMS to automatically publish content to. This post will continue the series by showing you how to create the last piece of setup that we need, the Facebook App and the Facebook Page. So if you have not read the introduction post please do so now, and then come right back.


Setting Up a New Facebook App

The process is largely the same for Facebook as it was for Twitter. To get started, log in to Facebook, navigate to and click on the Create New App button.


Facebook - Create New App


After proving you are indeed a human being you should be at a screen that shows you your API Key and App Secret key. Copy those and paste them into the Facebook settings back in Kentico.


Facebook - App Basic Settings


The second step of setting up the Facebook App is to add in a Canvas URL and Secure Canvas URL, this is the URL that the Facebook API will use to call back to obtain permissions and content for your Facebook App. For now we are in development mode so go ahead and enter in your local path that you are developing at. (i.e the localhost address that the visual studio built in web server is running or IIS Express) and don’t forget the port. Scroll down a bit on the basic settings page and click on App on Facebook.


Facebook - App Basic Settings URLs


Enter in your values into the Canvas URL, for me it was http://localhost:1469. Also populate the Secure Canvas URL with the same setting and replace http:// with https://. (https://localhost:1469). Then click Save Changes.

Next we need to create a Facebook Page to publish the updates to, or get the ID of the existing page you might already have. To create a new Facebook page navigate to click the Create Page button. I choose Brand or Product, you can choose whatever you want really. Fill in the category and give


Facebook - Create a Page


Now notice the URL in the browser. There should be a 15 digit key at the end of the URL. That is the Facebook Page ID that we need. Copy and paste that into the Facebook settings page back in Kentico CMS.

If you don’t want to create a new page and have an existing page that will work too. Click the More link next to Pages and Ads on your main Facebook menu.


Facebook - Main Menu


You should now be at a list screen of all of your pages. Click the page that you want to connect with, and then on the Edit Page menu click Update Info


Facebook - Get your Page ID


You Facebook Page ID should now be in the URL. Again it is the 15 digit key at the end of the URL. Copy and paste that into the Kentico Settings. You should now have the first 3 settings filled in on the General section of the Facebook settings, click Save. Next we need to get the Access Token.

Clicking the Get button on the Settings tab of Kentico should bring open up a popup window and redirect to Facebook automatically to make a permission request. It should look like this if you have everything in your Facebook App set up right.


Facebook - New App Auth Prompt


Click Go to App and allow the app to Post on your behalf in the next screen and click Allow. Now the first time I did this I got an error message. But that message gave me the Access Token and everything still worked. If that happens to you copy and paste the Token manually into Kentico. I think this is just an RC thing. I’m sure by full RTM this will be fixed to not have a false error message. If you do not see an error, click Finish on the popup window and the Access Token should populate to Kentico settings page.

That’s it for the setup of both Twitter and Facebook. You now have two new social media applications tied to your personal, company, or brand accounts that Kentico CMS will be able to automatically publish to.


Kentico CMS 7 Auto Publish Facebook Settings


That’s it for the setup of Facebook. You now have two new social media applications tied to your personal, company, or brand accounts that Kentico CMS will be able to automatically publish to.


Coming Up Next

Let’s move on to the conclusion of the series which will walk through how to use Kentico to automatically publish content to the social network of your choice.

Also a small rant here. Facebook has been around for awhile now, and after all this time do you think Facebook could seriously settle down and not change this process for a long period of time for once? I swear every six months or so there’s a whole different naming structure, API, or sweeping change to writing apps for Facebook. Sheesh.