Social Post Facebook allows you to configure your site to automatically publish an organization's Facebook page or group. It is based on Social Post and is part of the Drupal Social Initiative.
8.x-1.x/8.x-2.x: On August 1, 2018 facebook deprecated the publish_actions permission, breaking this module.
3.0.x: The Drupal 9+ version of this module is functioning, but now only support posting to pages, not individual Facebook user account walls. This is due to restrictions on usage of Facebook's Graph API.
1. To create an application on Facebook
The Application is what your web site will use to authenticate to Facebook and ask a user to grant privileges to post to your pages. You'll need the Application created and to add it's settings to your Drupal configuration so that it can prompt to request permissions. Essentially, the Application acts as an agent for your website to create posts.
Go to the developer center at https://developers.facebook.com/ and go to "My Apps"
Create an application:
Provide some name and an email for the application. The name of the application will appear on posts as the "Published by"
For permissions, select the use case "Manage everything on your Page".
There's no requirement to select a business portfolio for this application.
Click next until you are able to complete creating the application.
Ensure you are on the application dashboard. This should be where you land on upon creating the app. If not, select the application in the list of applications.
Select the "Customize the Manage everything on your Page use case", and ensure the following permissions are granted:
- pages_manage_posts
- pages_show_list
- public_profile
- pages_read_engagement (seems needed on use case, but not on business configuration?)
Click Add next to any that are not enabled. No additional permissions should be needed, so remove others if you'd like.
Return to the application dashboard, and expand the Facebook Login for Business and go to the settings.
Add Valid OAuth Redirect URIs to reach back to your application. You'll want to add one for each domain you need to reach. For example, to reach a live example domain and also test with your DDEV instance, add:
https://example.ddev.site/user/social-post/facebook/auth/callback
https://example.com/user/social-post/facebook/auth/callback
Now add a login configuration. This is also under Facebook Login for Business called Configurations.
Call the configuration anything you like, for example "user_login".
Use the general login variation.
Select user access token.
Under permissions, add the pages_manage_posts, email, pages_read_engagement, and pages_show_list permissions. When finishing the creating the configuration, make note of/copy the configuration ID (you can still get this from the configuration list if you missed it).
This should be sufficient configuration to use your app. Now, acquire the ID/secret you'll need - along with the configuration ID - to add to Drupal.
On the left, under App Settings, go to the Basic Settings. Copy the following:
App ID
App Secret
Then under App Settings go to the Advanced Settings. Make note of the API Version. Remember this location - Facebook will periodically deprecate API versions, and this value may need to be changed in the future.
2. Create a page
If you've already done this, skip this section. Creating a page is pretty straightforward. Logged in, on the main facebook page, click on see more in the left sidebar. Then click "pages". From there, click "Create new page" and just follow the prompts until your page is complete.
3. Configure Drupal
Add your App ID, App Secret, and Configuration ID to your Drupal configuration at `/admin/config/social-api/social-post/facebook`. Also ensure the API version matches what was listed in the advanced settings of the application.
If you prefer to keep your settings in your `settings.php` (or e.g. `settings.local.php` as applies to your usage style/environment), the structure looks like this:
$config['social_post_facebook.settings'] = [
'app_id' => '1234567890123456',
'app_secret' => 'bMYAPPSECRETETC',
'graph_version' => '23',
'config_id' => '0987654321098765',
'oauth_redirect_url' => 'https://example.ddev.site/user/social-post/facebook/auth/callback',
];*Dev note: the oauth_redirect_url should default to Drupal's hostname/user/social-post/etc... if it does not already*
4. Connect your facebook user to your Drupal instance
When logged in as the user you want to associate with your Facebook account, go to your users edit page, and click "Add account" under the Social Post Facebook section.
After authenticating and during authorization, ensure you select the option "Opt in to current Pages only", and select ONLY the one page that you will want to allow the app to post as. This module does not currently support authorizing posting to multiple pages on behalf of an individual account.
In the module settings, there is also the option to add a sitewide user, one that is not connected to a specific user.
5. Post to facebook
There are several ways to make posting happen. The simplest is probably via the ECA action plugin. This method will require setting up ECA on your site and configuring a model that makes use of the Post action. The action configuration allows you to configure which user's page (by user id) should be posted to when the action is invoked. If you want to post to the sitewide user's page, use the user id 0.
Project information
Seeking co-maintainer(s)
Maintainers are looking for help reviewing issues.- Project categories: Import and export, Integrations
- Ecosystem: Social Post
9 sites report using this module
- Created by gnuget on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.






