2017 © Pedro Peláez
 

library php-sdk-met-api

PHP SDK Bokbasen's Metadata API

image

bokbasen/php-sdk-met-api

PHP SDK Bokbasen's Metadata API

  • Wednesday, October 11, 2017
  • by bokbasen
  • Repository
  • 2 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

php-sdk-met-api

SDK for working against Bokbasen's Metadata API. Currently only exports are supported., (*1)

The SDK assumes working knowledge of the API, see documentation: https://bokbasen.jira.com/wiki/spaces/api/pages/61964298/Metadata, (*2)

Authentication

This SDK requires the Bokbasen API Client, see php-api-client for details on how to implement., (*3)

All code examples below assumes that this variable exists:, (*4)


ONIX Exports

Create ONIX Export client

Use auth object and set your subscription when creating the export object (subscription is based on your contract with Bokbasen. basic, extended or school), (*5)

<?php
use Bokbasen\Metadata\Export\Onix;
$onixClient = new Onix($client, Onix::URL_PROD, Onix::SUBSCRIPTION_EXTENDED);
?>

Get ONIX for single ISBN

<?php
$onixAsString = $onixClient->getByISBN('9788276749557');
?>

Download ONIX to file based on a date

This is only used when you do not have a valid next token. Given filename will be appended until all pages are fetched (if $downloadAllPages === true), (*6)

<?php
$nextToken = $onixClient->downloadAfter(new \DateTime('2017-01-01'),'/onixFolder/');
//Save next token for later use
?>

Download ONIX to file based on a token

Use $nextToken to get all changes since last execution, (*7)

downloadNext($nextToken,'/onixFolder/');
    $nextToken = $onixClient->getLastNextToken();
}

//Save next token for later use
?>

Get XML as string

If you do not want to use the SDK to write files for you, use the following methods to get the full Response object for each request. This means you need to implement the header parsing logic yourself., (*8)

getAfter(new \DateTime('2017-01-01')); 
//Implement your own parsing here and get token from header

//Use token to get more pages
$response = $onixClient->getNext($token); 
?>

Object Exports

Object reports has a similar process as ONIX download when it comes to paging. The SDK abstracts the report aspect and download the actual files for you., (*9)

Download all objects changes after a certain date

This is only used when you do not have a valid next token., (*10)

<?php
$nextToken = $objectClient->downloadAfter(new \DateTime('2017-10-01'),'/pathForObjects/');
//Save next token for later use
?>

Download objects to file based on a token

Use $nextToken to get all changes since last execution, (*11)

downloadNext($nextToken,'/pathForObjects/');
    $nextToken = $onixClient->getLastNextToken();
}

//Save next token for later use
?>

Additional filters

downloadAfter(new \DateTime('2017-10-01'),'/pathForObjects/',[\Bokbasen\Metadata\Export\Object::OBJECT_TYPE_AUDIO_SAMPLE,\Bokbasen\Metadata\Export\Object::OBJECT_COVER_IMAGE_SMALL]);

//you can also download for spesific ISBNs ($downloadAllPages must be true for this to work, and ensure to set a old date)
$objectClient->downloadAfter(new \DateTime('1950-01-01'),'/pathForObjects/',[\Bokbasen\Metadata\Export\Object::OBJECT_TYPE_AUDIO_SAMPLE,\Bokbasen\Metadata\Export\Object::OBJECT_COVER_IMAGE_SMALL],true,['9788251824491','9788215012520']);
?>

The Versions

11/10 2017

dev-master

9999999-dev https://github.com/Bokbasen/php-sdk-met-api

PHP SDK Bokbasen's Metadata API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ketil Stadskleiv

30/08 2017

v2.1.0

2.1.0.0 https://github.com/Bokbasen/php-sdk-met-api

PHP SDK Bokbasen's Metadata API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ketil Stadskleiv

26/06 2017

v2.0.0

2.0.0.0 https://github.com/Bokbasen/php-sdk-met-api

PHP SDK Bokbasen's Metadata API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ketil Stadskleiv

03/03 2017

v1.0.0

1.0.0.0 https://github.com/Bokbasen/php-sdk-order-api

PHP SDK Bokbasen's Metadata API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ketil Stadskleiv