July 2012 » Automatically Post Your Content to Twitter and Facebook using Kentico CMS 7 - Part 3
Jul 14

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

In part 1 of this mini blog post series we setup a Twitter App that we will connect Kentico CMS to automatically publish content to. In part 2 of the series we walked through doing the same thing but with Facebook. Now as we wrap things up, this post will complete the series by getting down to heart of the new Auto Publishing feature of Kentico CMS 7. So if you have not read the previous two posts in the series please do so now, and then come back for the finale.

 

Publishing Your Content Automatically

Now that your setup is complete, lets publish some content. Depending on which starter site you went with in your Kentico CMS 7 RC install you may or may not have a Blog setup. If you do go ahead and make a new post. If you do not please create a blog in Kentico first. After your new post is there navigate to the Form tab of that post and scroll down to the bottom of the page.

 

Kentico CMS 7 - New Blog Post with Facebook and Twitter Integration

 

At the bottom of the page you will see two new Form Controls that handle the automatic publishing to Twitter and Facebook. These controls show up correctly if you are using the default Document Type for blog posts in Kentico CMS 7.

A few things to notice here. At first the Auto Post fields will be blank, you do have to fill them in. I thought that be default they may have an automatic link to some of the document content, but they don’t. The two fields are long text so nothing fancy is allowed, i.e. no pictures or media files yet, but for most people I think text would be just fine, especially on Twitter.

You also have two publishing options. You can check the box that says Post at Twitter after publishing or Post at Facebook after publishing and the content will automatically get sent to Facebook or Twitter when the document gets published. The second option allows you the ability to click the Post on Twitter or Post on Facebook buttons whenever you want.

The nice thing is that the system stores your Facebook post or Tweet and you can come back to the document at any time you want to re-promote your content. Just please don’t spam anyone no one likes that. Also when you do come back the control provides you with a link to Tweet and a status message that says the Tweet or Facebook post was already published.

 

The Results

After pressing the Post buttons, or publishing your shiny new document the magic should happen. A green notification message should appear alerting you the action succeeded. If something went wrong you will see the dreaded red error message as well. Remember Twitter does have a 140 character limit, don’t try to push any limits here.

If you head on over to your Twitter account you should see your new Tweat. Notice that the name of your app shows up below your tweet on Twitter, and the same thing happens on Facebook. So name your apps appropriately.

 

Follow me on Twitter @mcbeev

 

The updated Facebook timeline screenshot below shows that he post worked correctly.

 

Follow me on Facebook at facebook.com/mcbeev

 

Pretty cool eh ? Especially since we didn’t have to write a single line of code.

 

 

Adding Auto Publishing to Custom Document Types

I did promise one extra tip way back at the beginning of this blog post series. That tip was to add the automatic publishing feature into any Document Type you wanted, not just CMS.BlogPost. It’s actually really easy to do. Here is what the Blog Post Document Type looks like. Notice that on the field chosen, the Form Control option is set to Facebook auto post. As you could probably guess the Twitter field is set to Twitter auto post.

 

Kentico CMS 7 - Document Type Properties

 

Those two Form Control types are what the code looks for to see if the Form tab on CMSDesk should show the new Auto Publishing feature. The code looks for any field that ends in AutoPost in the field name of a Document Type and has Long text attribute as it’s type. So to add in this new feature to your own custom Document Types, add a new field and give it a name that ends with AutoPost, select Long text, and set the Form control type to one of the auto post options. I followed that logic for the CMS.News document type that comes in the E-commerce start site and got the following results.

 

Kentico CMS 7 - Document Type Properties Auto Post

 

Clicking Save on the Document Type results in the CMSDesk Form tab showing the new Auto Post control on any document that uses your custom Document Type. All the same great functionality of the blog post Document Type is now open to you.

 

Kentico CMS 7 - CMSDesk CMS.News New Document

 

 

Conclusion

As you can see the real work here is involved in setting up your social media side of things as a Twitter App, Facebook App, and Facebook page. Once those are setup Kentico makes it extremely easy to push the content there. I think this feature is extremely useful for anyone using social media. And if you aren’t using social media what rock have you been living under for the last 5 years ?

And since we are talking about social media here, if you liked this blog post series and/or my blog in general go ahead and follow me on Twitter, Facebook, or Google+.

 

You might also be interested in

[X]

Be the first to know about my latest Kentico Tips & Tricks!

Do not show again