eZ Publish Social Media Integration: Publishing

by Serhey Dolgushev | October 10, 2012 1:26 pm

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[1], 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[2]. 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

  1. 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.
    [3]
  2. Click “New workflow” button.
    [4]
  3. 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

    [5]

  4. After workflow event is created you can settup social network publish handlers using workflow event editing interface. Select ‘Facebook’ and click “Add” button.
    [6]
  5. 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.
    [7]
  6. 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.
    [8]
  7. 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.
    [9]

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:

Please feel free to extend nxc_social_networks extension with publish handlers[10] 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.

Endnotes:
  1. Sign-on buttons: http://blog.nxcgroup.com/2012/ez-publish-social-networks-integration-signin/
  2. OAuth 2.0 protocol: http://oauth.net/2/
  3. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/workflow_groups.jpg
  4. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/new_workflow.jpg
  5. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/creating_workflow.jpg
  6. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/adding_publish_handler.jpg
  7. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/adding_class_attribute.jpg
  8. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/publishing_options.jpg
  9. [Image]: http://blog.nxcgroup.com/wp-content/uploads/2012/10/triggers.jpg
  10. publish handlers: https://github.com/nxc/nxc_social_networks/tree/master/classes/handlers/publish

Source URL: http://blog.nxcgroup.com/2012/ez-publish-social-media-integration-publishing/