Skip to content

Latest commit

 

History

History
70 lines (53 loc) · 2.94 KB

README.md

File metadata and controls

70 lines (53 loc) · 2.94 KB

eZ Publish REST API Demo

This repository contains a very rough example of the usage of the REST API in JavaScript presented at the eZ Unconf #2 in 2013.

The application allows to take a picture with the webcam of the computer and to create the corresponding Image content in the eZ Publish repository with the REST API!

Requirements

Install

  • Clone this git repository

  • Copy or symlink the demorest folder into the web folder of eZ Publish

  • If you installed the rewrite rules for a virtual host setup, you need to add the following rewrite rule right before RewriteRule .* /index.php:

    RewriteRule ^/demorest/ - [L]

Usage

  • Go to http://[ezpublish-url]/demorest/
  • The browser should ask for the permission to use the webcam
  • Click on Capture! to take a picture with your webcam
  • In Your profile part, fill a name and click on Publish
  • The first time you click on Publish, the browser should ask for a login and a password of an eZ Publish user with the permission to create content
  • The log part in the right should fill itself with messages and at the end of the publish operation, a link to the newly created content should be available

Here are the results in one screenshot:

Screenshot of the app

A screencast is also available in REST API Demo application at the eZ Unconf blog post on share.ez.no (A french version of this post is also online).

Session authentication

Since eZ Publish 5.1, it's also possible to create a session through the REST API. The code to test this new feature is embed in the demo, but not activated.

Here are the steps to use this new feature:

  1. Close and open again your browser so that it forgets the basic auth
  2. Remove the cookies for the domain your are working on
  3. enable the session authentication in eZ Publish
  4. Unhide the login form by commenting the display: none CSS rule in style.css (around line 50)
  5. Uncomment the two //,'X-CSRF-Token': tokenEl.innerHTML lines (Warning: make sure to keep the comma at the beginning of those lines)

The first time you want to create an image, you now need to click on the Login! button to authenticate your self. The rest of the usage paragraph remains the same.