Useful tips by the developers of our Drupal development company make social networks closer and your life easier ;) Once we told you about Drupal modules for social network integration. Now it’s time to discuss Facebook auto posting.
Today, if a website doesn’t have its own page in at least one social network, it is considered incomplete and is unlikely to get high ratings. Lots of people almost live in social networks and follow websites’ news directly from there. Thus, to make your life easier and avoid posting your news both on your website and on your social media page, consider setting up auto posting. This way, when you post something on your site, it will automatically be published on your social media page as well.
Today, I'll tell you how to set up auto posting from a Drupal site to Facebook.
So let’s start.
First, you need to create your own application (New App) https://developers.facebook.com.
Select "Web page". Next, Facebook lets you name your application. After that, you will be offered codes to embed on your site. We are not interested in those right now, so let’s just fill in the site address. Then you will see the application main page.
On this page, you'll see an App ID (the ID of your application that you will be using in the future) and an App Secret (the application secret key).
Then go to "Settings" page.
Fill in "Namespace", write the website domain, your email and website address. Save. If you do not have the block with the website address, then click "+ Add Platform" and select "Web Page".
Then go to the "Status & Review" page and enable your application.
We are through with the Facebook settings. The next step is to configure Drupal. For that, we need Facebook Autopost module and facebook-php-sdk. Enable the Facebook Autopost module, and put facebook-php-sdk in the libraries' folder. Go to the /admin/config/services/fbautopost module settings page.
Insert App ID and App Secret from your application page on Facebook. Save it and log in. Once you are logged in, you will be able to choose a page where to post.
You also need to give permission to the Facebook Autopost app on the admin/people/permissions page. Next, if you want to be able to choose which content to post, you need to check the "Post to Facebook" mark. To do that, add a field in the type of content you need to post (it is desirable not to change the machine name).
You should also look at the page of Facebook publication type settings: admin/structure/facebook-publications. Here you can configure the publication types. By the way, when creating rules, we will use fields of the type that are present on the page.
Rules
To make everything work, you need to create another rule: admin/config/workflow/rules. Name it "Post to Facebook after making an update".
Events
Conditions
In conditions, choose what type of content to post and see whether there is a check mark in the "Post to Facebook" field. For automatic posting you can skip this check and not create the check mark.
Actions
Create a new entity to transform your content type into the type that you can post on Facebook.
Then convert the fields of your content type into corresponding fields of content for posting.
When the required fields are converted, the most important part begins — posting on Facebook. Create the "Publish to Facebook page" action.
To keep control over what you post, save your entity. That's all.
Now let's talk about possible mistakes. The most common error is “Insufficient permissions to publish on page with id xxxxxxxxxxxx. Please check your configuration.” Here you just need to verify that you have correctly specified the page for posting in the settings/admin/config/services/fbautopost and the page where to post in the rules.