Publishing Drupal 7 Content to Social Media: Part 2Publishing Drupal 7 Content to Social Media: Part 2
Today we're going to look at how to push your site content to social media services using contributed Drupal modules. If you want full control over how social media integrates with your site and allow extra features to be used on site, this is the way to go. The major tradeoff comes with increased time for configuration and testing, and possibly troubleshooting if something doesn't work correctly.
Let's get started.
Using TwitterPushing site content via Drupal modules
There are several steps we have to take on Twitter's end before we can proceed. The first thing you want to do is login to your Twitter account and add your mobile phone number to your account. This is required by Twitter Application Management.
Next head over to https://apps.twitter.com/app/new and create a new application. Fill in your fields and create the app. This is required in order to establish API keys to talk to Twitter from your Drupal site.
Upon creating your app you should see a screen with several options. This first thing you want to do is head to "Premissions" and change it to "Read & Write." After that head to "Keys and Access Tokens" and note your API keys.
Head back to your Drupal installation and install Twitter and OAuth modules. Next, navigate to /admin/config/services/twitter/settings and add your API keys. Note your Callback URL as you will need this for the next step.
Head back over to the Twitter Application Management site and head to the Settings page and add the Callback URL that your Drupal installation indicated. After that head to "Keys and Access Tokens" and lastly, hit the button at the bottom to "Generate access token."
Head back to your Drupal site again, this time to /admin/config/services/twitter and click the button to authenticate with your account. You should be redirected to a Twitter page where you enter your username and password. After you've done that you get redirected back to your site and you're up and running! You should see a screen like this:
Next head to /admin/config/services/twitter/post and enable posting based on one or more content types.
Create a piece of content and post it to test.
Go grab the Facebook Autopost module, Entity API, and Rules modules (and possibly Features if you need it) from the Drupal website. Go and grab the package from https://github.com/facebookarchive/facebook-php-sdk and place the content in a directory located at /sites/all/libraries/facebook-php-sdk. After that, install all modules.
Next login to your Facebook account and then go to https://developers.facebook.com and register if you need to. On the Apps menu click to create a new app.
Go to "Settings" and add your site URL and a contact email. Next go to "Status and Review" and switch to make the app available to the public. Lastly go to "settings" and note your App ID and App Secret.
Go back to your Drupal site to /admin/config/services/fbautopost and copy in your IDs. Save the configuration and then sign in to Facebook via the link to connect the site with your App.
Next head to /admin/config/workflow/rules and create a new rule. The main event should occur when saving a new piece of content. You will then create at least 3 actions. This first will be to create a new Facebook publication entity. The second populates the entity with some value from your content type (like a link or text summary). The last publishes it. You can see below for my settings, although for a more in depth look I suggest you look at this video which walks through everything in more detail.
That does it. You now have some tools that should allow you to have fine grained control over your social media posts.