YUDU Publisher REST API Library - PHP

1.0.3 2019-06-25 15:09 UTC

This package is auto-updated.

Last update: 2020-12-29 18:45:35 UTC


Build Status Latest Stable Version Total Downloads License

This repository is a convenient wrapper library in PHP used to interact with the YUDU Publisher REST API. The library enables simple access to the YUDU Publisher REST API via convenient and simple to use helper methods.

The building of request headers and signatures is abstracted away to make working with the API straightforward.

To gain a deeper understanding of the YUDU publisher REST API please see here for more details.

This library is intended as an example to assist developers in their interaction with the YUDU Rest API. The creators are not liable for how the library is used and as such it is the responsibility of any users of the library to ensure the testing and resilience of their own production systems.


This library can simply be installed with composer via packagist by using:

composer require yudu/publisher

If unfamiliar with composer more information can be found here

How to get started?

To use this library you will need an active YUDU Publisher Key and Secret. The Key and Secret are required to create a Publisher client. Once instantiated the Publisher client can be used for multiple requests. The results can be transformed as required. Below demonstrates how the publisher client can be created and used.

require 'vendor/autoload.php';

use Yudu\Publisher\Publisher;

// YUDU Publisher Credentials
$key = 'your-key-here';
$secret = 'your-secret-here';

// Optional
$options = [
    'debug' => false,    // raw requests/response returned for debugging
    'verify' => true,    // toggle SSL verification 

// Create Publisher Client
$publisher = new Publisher($key, $secret, $options);  

// Makes request for readers
$results = $publisher->getReaders();

// Print the result object (see responses section for how to manage responses) 

Available methods and examples

Get Links


Get all readers


Get reader


Create reader

    "username"      => "example",
    "emailAddress"  => "example@example.com",
    "firstName"     => "Micky",
    "lastName"      => "Jackson",
    "password"      => "NvrrL@nd!",
    "nodeId"        => "347358",

Update reader

    "username"       => "updated",
    "emailAddress"   => "updated@example.com",
    "firstName"      => "Joe",
    "lastName"       => "Bloggs",
    "password"       => "GIU^&Gkdk24",
    "nodeId"         => "347358",

Delete reader


Get Editions


Get Edition


Create Edition

    "name" => "My Edition",
    "onDeviceName" => "My Edition",
    "shortName" => "MY1",
    "targetState" => [
        "web" => "LIVE",
    "documentUrl" => "https://s3-eu-west-1.amazonaws.com/my.account/test/example.pdf",
    "publicationNodeId" => "4325325",
    "pageBillingType" => "PLATFORM"

Update Edition

$publisher->updateEdition(6894180, [
    "name" => "My Edition",
    "onDeviceName" => "My Edition",
    "shortName" => "My Edition",
    "drmEnabled" => "true",
    "iosSaleOption" => "FREE",
    "androidSaleOption" => "FREE",
    "enableSharingByEmail" => "false",
    "enablePrinting" => "true",
    "targetState" => [
        "web" => "LIVE",
    "pageBillingType" => "PLATFORM"

Delete Edition


Get Permissions


Get Permission


Create Permission

    'reader' => 2356346,
    'edition'=> 6795595,

Update Permission

$publisher->updatePermission( 132365, [
    'expiryDate' => 2356346,

Delete Permission


Get Reader Logins


Get reader Login


Get Publications


Get Publication


Get Subscriptions


Get Subscription


Get Subscription Periods


Get Subscription Period


Create Subscription Period

    'reader'       => 126417872,
    'subscription' => 6482745,
    'startDate'    => '2019-01-11T00:00:00Z',
    'endDate'      => '2020-01-11T00:00:00Z',

Update Subscription Period

$publisher->updateSubscriptionPeriod(2351346 [
    'startDate'    => '2020-01-11T00:00:00Z',
    'endDate'      => '2021-01-11T00:00:00Z',

Delete Subscription Period


Remove Devices


Authenticate Password


Create Token (Access to any edition)


Create Publication Token (Access editions at publication)

$publisher->createPublicationToken('admin@exmaple.com', 1246457);

Create Edition Token (Access single edition only)

$publisher->createEditionToken('admin@exmaple.com', 74244556);

Send Targeted Notification

$publisher->sendTargetedNotification(7145646, 'title', 'message', ['admin@example.com'], [ 356h64gqh65h545vhj6, 4574655w5ujw65w5a5], 'HIGH', 'false');

Get Categories


Create Category

    'categoryTitle'     => 'How to build a time machine',
    'code'              => 'adventure',
    'containsAll'       => 'true',
    'defaultCategory'   => 'false',
    'ordering'          => '4',
    'publicationNodeId' => '61',

Delete ALL Categories (from specific node)


Get Specific Category


Update Category

    'categoryTitle'     => 'Do you remember the time?',
    'code'              => 'adventure',
    'containsAll'       => 'true',
    'defaultCategory'   => 'false',
    'ordering'          => '4',
    'publicationNodeId' => '61',

Delete Category

$publisher->deleteCategory('adventure', '61');

Get Category Editions


Create Category Edition

    'code'              => 'adventure',
    'editionId'         => '64562',
    'publicationNodeId' => '61',

Delete Category Edition

    'publicationNodeId' => '61'
    'code'              => 'adventure'

Custom Request

In addition to using the methods above, it may be desirable to build the request manually. If this is the case the underlying request methods are exposed and chainable so that any request can be made. It doesnt matter what order the chained methods are added so long as the make() method is that last method to be called.

For example:

$results = $publisher->method("GET")->resource("readers")->make();

Handling responses

After making a call to Publisher a ResponseHandler object is returned. The Responsehandler is a wrapped Guzzle response which reveals convenient methods to assist in transforming the response into a chosen format.

Below demonstrates the methods that can be used after making a request:

// Makes request for readers ($results is a ResponseHandler Object)
$results = $publisher->getReaders();

// Get the request HTTP status code e.g 200
$status = $results->statusCode();   

// Convert results to Simple XML Object 
$xml_object = $results->xml 

// Convert results to XML string
$xml_string = $results->xmlString();

// Return the raw guzzle object
$guzzle = $results->guzzle();

// Return raw http request/response string
$raw = $results->raw();

// Echo Casts results to string 
header("Content-type: text/xml");
echo $results; 

Issues / Support

General support issues can be directed to support@yudu.com

When requesting support it will be helpful if you can provide the raw requests and responses for any api call you are attempting. This can be obtained by passing [ 'debug' => true ] in the options array when instantiating the publisher library.

If you encounter a bug or have a technical question please open an issue on this repository.