Open Source | Technology | Web

eZ Publish Social Media Integration: Publishing

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

  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.
  2. Click “New workflow” button.
  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

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

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.

Print this post

9 Responses to "eZ Publish Social Media Integration: Publishing"

  1. john   on Tuesday, October 30

    Hi,Thank you very much for your extension and I have problem while configure the workflow , I cant see the list name ” Event type: ‘Event / Publish to Social Networks’ ,can you please guide me ,how to do? ,thanks in advance !

    (reply)
  2. Eirik A. Johansen   on Tuesday, December 11

    Having set this up and trying to publish to Twitter, I get the following error:

    PHP Fatal error: Call to a member function attribute() on a non-object in /mnt/data/eirik/www/landbruk/extension/nxc_social_networks/classes/handlers/publish/twitter.php on line 53

    In line 48 I tried changing

    $OAuth2Token = $OAuth2->getToken();

    to

    $OAuth2Token = $OAuth2->getAccessToken();

    and allthough this gets rid of the fatal error, no data is published to Twitter. It’s the Oauth settings consumer key and consumer secret I should be using, right?

    (reply)
  3. Serhey Dolgushev   on Wednesday, December 12

    Hi Eirik,
    You should not change the source code.
    Seems like there is no generated access token at yout side. http://blog.nxcgroup.com/2012/ez-publish-social-media-integration-feeds describes how to generate access tokens in ezp back-end. Please check it.
    Please also do not forget to set up twitter API application (http://blog.nxcgroup.com/2012/ez-publish-social-networks-integration-signin).

    (reply)
  4. Steven   on Thursday, January 24

    Hi,

    I just tried this extension and it works great !
    Very nice work !

    I have a question though : one of my customer would like to be able to publish content to multiple (450 !!) twitter accounts.
    Indeed, they regularly create new twitter accounts for their contributors and would like each contributor to be able to publish content (always same content class) to its own twitter account (of course with dev app created first and access tokens generated for each twitter user).
    Do you think this would be possible with your extension ?
    Would it need to change the source code a lot ?

    Thanks for your answers.

    (reply)
  5. Serhey Dolgushev   on Friday, January 25

    Hi Steven,
    Our extension is perfect for your case. But it requires a bit changes to completely satisfy your needs:
    – unique assecc token should be stored per each user (maybe user content object attribute should be used for storing the token)
    – workflow logic should be changed to retrieve the token from current logged in user object attributes (it fetches the token from DB now)
    Please contact us, if you need some help in it`s implementation.

    (reply)
  6. Steven   on Friday, January 25

    Thanks a lot for your answer.
    I’ll get in touch with you when I’ll start implementing it.

    (reply)
  7. Sander   on Monday, June 10

    I just gave your extension a try, and just wanted to give a compliment ;) It’s working like a charm out of the box! Thanks for sharing this great work.

    I have the need to publish to social networks only for specific new articles, so I want more control over the post publish handler. Any suggestions how to implement this?

    Regards,
    Sander

    (reply)
  8. Haddad Amine   on Thursday, September 12

    Hi,
    My customers wants to share content from the front end with a share button, I want to know if the extension can do this ?

    (reply)

Reply to john

Get latest news