In the previous blog posts we demonstrated how to fetch data from social networks and use it in an eZ Publish template. This blog post describes how to easily post content to the social networks (Facebook, Twitter, LinkedIn) from eZ Publish.
How it works
nxc_social_networks extension provides an eZ Publish workflow event type. It allows extracting content from a published eZ Publish object and pushing it to social networks (Facebook, Twitter, LinkedIn). Currently, it appears that the Google+ API does not allow publishing of any content on behalf of a user.
The described functionality requires creating social network applications. If you have set them up while implementing Sign-on buttons, use the same ones, no need to do it again. Similarly to fetching feeds from social networks, eZ Publish interacts with social networks via OAuth 2.0 protocol. It means that access tokens are required. If you have generated them while implementing Feeds, use same ones, no need to generate new ones.
The last thing that should be completed in order to enable publishing to social networks from eZ Publish, is set up a workflow.
Set up a workflow
Go to ‘Workflow groups’ page in eZ Publish back-end (admin.yoursite.com/workflow/grouplist). Click “Standard” workflow group. Or create your own workflow group.
Click “New workflow” button.
Create new workflow:
Name: ‘Publish to social networks’, or you can use your own one, if you wish
Event type: ‘Event / Publish to Social Networks’
Click on the “Add event” button
After workflow event is created you can settup social network publish handlers using workflow event editing interface. Select ‘Facebook’ and click “Add” button.
You can choose any class attributes. At the moment “Text line” and “Text block” eZ Publish datatypes are supported. Content of selected attributes will be published to the corresponding social network. You can select as many attributes as you wish for each social network.
After you have added all the desired social network publish handlers and their class attributes, you can select options for each social network publish handler. Once finished, remember to click “OK” button at the bottom of the page. Workflow event will be stored in the system.
Go to ‘Workflow triggers’ page (admin.yoursite.com/trigger/list). Select ‘Publish to social networks’ workflow for ‘content/publish/after’ trigger and click “Apply changes” button.
That’s it. Each time a new article is published in eZ Publish, its title and URL will be sent to Facebook, Twitter and LinkedIn. As you can see, it is very easy to set up social network publishing. You can:
use any social networks
enable publishing for any class attributes
use any options
Please feel free to extend nxc_social_networks extension with publish handlers for any other social network. If you have any questions, ask them in the comments section.
We hope the nxc_social_networks extension will be useful and make your life a bit easier. Please subscribe to our feed for some helpful knowledges, that we will continue sharing with you.