The Cheeky Monkey Media Blog

A few words from the apes, monkeys, and various primates that make up the Cheeky Monkey Super Squad.

Send your content to social networks banner

A few months ago I was asked to help manage our company blog. As a busy drupal website developer, I had little time to post all of our new blog content on every social media site. So I decided to automate this so I could spend more time on client projects.

My first step was to look around and see what was currently available. Although there were some options, I found them to be a bit heavy for my application.

One of the things I was looking for was to be able to choose what social networks our content would be posted to. For example, I wanted to be able to choose to post this page to Facebook, but not Twitter, or post this to all social networks.

So I decided to build my own solution and here is how I did it (or just download the code from GitHub).

Required Drupal Modules:

  • Taxonomy
  • Views
  • Features (if you’re downloading the code)

Add New Taxonomy Vocabulary

The first step is to create a new taxonomy vocabulary called “Social Networks.” This will allow us to associate a social media site with our content. Next, we will want to add a few terms, like Facebook, Twitter, Google Plus, and LinkedIn.

Now that we have our taxonomy setup, we need to add a new field to our blog content type. To do this, add a new term reference field called “Post To Social Networks.” Although you can use whatever widget you think would work best, I went with the checkboxes/radio buttons option. Make sure to select the “Social Networks” vocabulary and the “unlimited value” option.

You will probably want to make sure this new field is not displayed on the actual post, so go to the manage display page and set this field to “hidden”.

Next, we will need to create some dummy content to work with or edit some existing posts. Once we have some content tagged with our social media sites, we then turn to views and create a new feed.

Configure Views and Social Feeds

Next, we will need to add a new relationship to our feed (we will need this for our argument).  Add the “Taxonomy terms on node” relationship and select the vocabulary that we created in the first step, leaving the other settings default.

Now for the fun part, we will need to add a contextual filter. Add the “Taxonomy term: Name” filter and make sure to use the term relationship that we just set up. Under the “When the filter value is NOT in the URL” select  “Provide default value” and choose “taxonomy term id from URL”.

Now that we have our contextual filter setup, we need to set the feed path. I decided to use social-feed/%/rss.xml. The % is the argument, so this would be replaced by the term name (Facebook, Google, etc.).

Send Feed To Social Networks

So now that we have our vocabulary and RSS feed set up and working well, we need to be able to send these feeds to various social networks. We could create our own API call for each social network, but that would be a bit more complicated for this tutorial. Instead, let’s use a service that’s already built.

Some options to choose from include; If This Then That (IFTTT), Buffer, and Hootsuite. My decision was easy, our company already had a Hootsuite account, so I logged in and went to work. This part is fairly easy; go to settings and select “RSS/Atom and add a new feed.

Now add the feed URL that we configured earlier using views ( select the network to send the feed to (Facebook, Google Plus), and you’re done. You will want to repeat this step for each social media site.

Now, if you have everything set up properly when you add a new blog post, it will be posted on all your social networks. Finally, you can breathe easy and thank me for all the time I just saved you and your clients!