Skip to content

Instantly share code, notes, and snippets.

@bdunogier
Created March 9, 2014 14:51
Show Gist options
  • Save bdunogier/9448935 to your computer and use it in GitHub Desktop.
Save bdunogier/9448935 to your computer and use it in GitHub Desktop.
Usage example of the native eZ Publish 5 REST API PHP Client.It comes as a reimplementation of the Repository APIs, allowing the same code to be used for a local and a remote eZ Publish instance. Work in progress branch: https://github.com/bdunogier/ezpublish-kernel/compare/rest_client_relaunched. Specifications at https://github.com/bdunogier/e…
<?php
$loader = require 'vendor/autoload.php';
$repositoryFactory = new \eZ\Publish\Core\REST\Client\RepositoryFactory();
$repository = $repositoryFactory->create( 'http://php55-vm.ezpublish5/', 'admin', 'publish' );
print_r(
$repository->getContentService()->loadContentInfo( '/api/ezp/v2/content/objects/59' )
);
/*
$ php test2.php
eZ\Publish\API\Repository\Values\Content\ContentInfo Object
(
[id:protected] => /api/ezp/v2/content/objects/92
[contentTypeId:protected] => /api/ezp/v2/content/types/19
[name:protected] => Discover eZ Publish 5
[sectionId:protected] => /api/ezp/v2/content/sections/1
[currentVersionNo:protected] => 1
[published:protected] => 1
[ownerId:protected] => /api/ezp/v2/user/users/14
[modificationDate:protected] => DateTime Object
(
[date] => 2013-01-30 16:39:28
[timezone_type] => 1
[timezone] => +01:00
)
[publishedDate:protected] => DateTime Object
(
[date] => 2013-01-25 17:11:47
[timezone_type] => 1
[timezone] => +01:00
)
[alwaysAvailable:protected] =>
[remoteId:protected] => ec8ceac6bc6c2d3cc8b4d3fbf5655914
[mainLanguageCode:protected] => eng-GB
[mainLocationId:protected] => /api/ezp/v2/content/locations/1/2/94
)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment