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)
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:
- First name
- Last name
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
Creating social network applications
Please follow these instructions to create an application in each social network
- Go to https://developers.facebook.com/apps and click “Create New App” button.
- Specify the application name, for example “eZ Publish Integration” and click “Continue” button.
- Add website.com to App Domains, and set http://website.com as Site URL. Click “Save Changes” button.
- Click on the application`s name in the page path.
- Update nxcsocailnetworks.ini.append.php (/ezpublish_path/extension/nxc_social_networks/settings/nxcsocailnetworks.ini.append.php) settings file:
[FacebookApplication] Key=APP_ID Secret=APP_SECRET
- Go to https://dev.twitter.com/apps/new and fill out the form:
- Name: eZ Publish Integration
- Description: eZ Publish Integration
- Website: http://yoursite.com
- Callback URL: http://yoursite.com/
- Apply Developer Rules
- Enter captcha
- Click “Create yout Twitter application” button
- Application will be created and you will be directed to it`s page. Open “Settings” tab.
- Select “Read and Write” Access and click “Update this Twitter application’s settings” button.
- Open “Details” tab after settings will be updated and update nxcsocailnetworks.ini.append.php (/ezpublish_path/extension/nxc_social_networks/settings/nxcsocailnetworks.ini.append.php) settings file:
[TwitterApplication] Key=CONSUMER_KEY Secret=CONSUMER_SECRET
- Go to https://www.linkedin.com/secure/developer and click “Add New Application”.
- Fill out the form:
- 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:
[LinkedInApplication] Key=API_KEY Secret=SECRET_KEY
- Click “Done” button.
- Go to https://code.google.com/apis/console/ and open “Services” tab.
- 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:
[GoogleApplication] Key=CLIENT_ID Secret=CLIENT_SECRET
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.
This work is licensed under a Attribution-ShareAlike 3.0 Unported License