eZ Publish Social Media Integration: Single Sign-on
by Serhey Dolgushev | September 26, 2012 9:53 am
We are happy to announce the nxc_social_networks eZ Publish extension. This extension implements full eZ Publish integration with social networks, and provides the following capabilities:
Sign-in button, which allows users to login/register via social networks (Facebook, Twitter, LinkedIn and Google) in one click
eZ Publish template fetch functions to obtain the social network feeds (Facebook, Twitter, Google+)
Publish to social networks from eZ Publish (Facebook, Twitter, LinkedIn)
This post covers the Sign-on button functionality, the remaining bullets will be discussed in our upcoming posts.
How does it work?
Each time a user clicks on any social media sign in button, they are directed to the appropriate social network. There the user should confirm the specific application can use their account data. Afterwards the user is redirected back to the website. At this point, the appropriate social network login handler checks if an eZ Publish user is already connected to the social network account. If this is the case, it will be used to authorize the user to eZ Publish. Otherwise the eZ Publish user will be created and used the next time. The eZ Publish user is created only once (when using the social network account for the first time), and not each time you click on the sign in button.
Please note that the following fields are extracted from social network account and are used within eZ Publish user account:
eZ Publish user content class should contain these attributes.
In order to enabled social network SignIn buttons do the following:
Install nxc_social_networks extensions
Create social network applications (for Facebook, Twitter, LinkedIn and Google)
Include a sign in button into required eZ Publish templates
Clone extension’s git repository from https://github.com/nxc/nxc_social_networks
Enable extension in the eZ Publish back end
Regenerate autoloads array
Execute MySQL code from /path_to_ezpublish/extension/nxc_social_networks/sql/mysql/mysql.sql file
Clear eZ Publish caches
The extension is now installed. The next step will be creating social network applications.
Creating social network applications
Please follow these instructions to create an application in each social network
Company: select some company from the available list
Application Name: eZ Publish Integration
Description: eZ Publish Integration
Website URL: http://website.com
Developer Contact Email: input an email address
Phone: input a phone number
Agreement Language: select the language from the available list
Agree to Term of Service
Click “Add Application” button
Application will be created and the user will be directed to its page. Update nxcsocailnetworks.ini.append.php (/ezpublish_path/extension/nxc_social_networks/settings/nxcsocailnetworks.ini.append.php) settings file:
Enable “Google+ API” Service. Afterward open “API ACccess” tab.
Click “Create an OAuth 2.0 cleint ID…” button.
Specify product name, for example “eZ Publish Integration” and click “Next” button.
Select “Web application” Application type
Clcik “Create client ID” button.
OAuth 2.0 cleint will be created and you will be directed to it`s page. Update nxcsocailnetworks.ini.append.php (/ezpublish_path/extension/nxc_social_networks/settings/nxcsocailnetworks.ini.append.php) settings file:
Applications for each social network are created and ready for use. Please, do not forget to clear INI caches.
The last step remains: include a sign in button into the eZ Publish templates.
Including Sign-in button
If the front-end siteaccess name is “eng” then user login template is overrided and it includes the sign-in buttons (after installing nxc_social_networks extension). But if you wish to add those buttons in any custom template you should just to include the following code:
Please, do not forget to clear template caches. After doing so, site visitors will be able to login/register using their preferred social network account.
If you have further questions, please review social network login handlers source code or ask questions in the comments. Stay tuned, the next post will describe how to fetch feeds from social networks and how to publish to them from eZ Publish.