Latest Register Log In

+ Advanced Search

Automatic Facebook Posting

Automatic Facebook Posting
By
22/03/21 (Edited 23/03/21)

If you want to tell your social media followers about every new listing you add, WSN can do that, although unfortunately facebook makes it a trillion times more complicated for you than it needs to be. At Admin -> Settings -> Social you'll find an option for automatic facebook posts. These posts will go to a facebook page you own, every time a listing is approved.

First, you'll need to set up a facebook app if you haven't already done that for the Facebook Connect login option. To create an app, go to https://developers.facebook.com/apps/ . The app display name and namespace can be whatever you want, but you must ensure to enter the domain your WSN is installed on in the app domains box. Copy the app id and app secret into the boxes at Admin -> Settings -> Social -> Auto-Facebook.

To find your facebook page id, go to your page and click About in the left column. Scroll down to find your Page ID below More Info. Enter that at Admin -> Settings -> Social -> Auto-Facebook -> Page ID.

Finally, the hard part is generating a facebook access token with the required permissions and making it last more than a few hours. Here's the process:
1. Go to https://developers.facebook.com/tools/explorer/
2. Select your app from the facebook app menu on the right.
3. Select your page from the "user or page" menu just below that.
4. Click into the "add a permission" box to start searching for permissions.
5. Search for and add the permissions pages_manage_posts and pages_read_engagement
6. Click the generate access token button.
7. Copy that token and paste it it in the text box on the Access Token Debugger at https://developers.facebook.com/tools/debug/accesstoken and then click the Debug button.
8. On the Access Token Debugger, scroll to the bottom of the page and click Extend Access Token.
9. Copy the new extended access token it gives you to Admin -> Settings -> Social -> Auto-Facebook -> Facebook Access Token.

Token Expiration

The most exhasperating issue here is token expiration. The token officially lasts only 60 days. However, Facebook says "the SDKs automatically refresh the token whenever the person uses your app, so the tokens expire 60 days after last use." What constitutes your use of the app remains to be determined. WSN will periodically check the token expiration time and warn you with an email alert if it's due to expire within two weeks, if you have facebook auto-posting turned on. Hopefully a simple process can be established to refresh the token so that you don't have to go through all these steps to create a new one every couple months -- this article will be updated when that process becomes clear.

Tokens are also invalidated when you change your facebook password, so beware of that. They may also be invalidated by logging out of Facebook, unless the offline_access permission is granted... but how to get the offline_access permission is unclear, so best not to logout (you don't need the page/app open, just to not specifically logout).

Testing

To give it a test without waiting for a new listing, and to make sure you see any error message that may occour, go to Admin -> Miscellaneous -> Advanced and run the following in the "run PHP" box:

facebookit("This is only a test, we will delete it shortly.");

Check your facebook page to verify and delete the post. If you get an error, read the error message carefully. If it tells you your token is expired, you'll have to create a new one. If it tells you it doesn't have enough permissions, make sure you add the specified permissions when creating a token. Also double check that you're creating a page token and not a user token.





Rating
Views 2 views. Averaging 1 view per day.
Similar Listings