DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: tail

Created:2013-04-09T09:53:23
Changed:2014-03-07T14:19:12.541000000
Classification:tail
Keywords:REST, rest, tail, restful, client, forDevelopers, forIntermediates
Author:Pascal Dürsteler
Email:welcome@notionlab.ch
Language:en

img-1 img-2 EXT: tail

Extension Key: tailLanguage: enKeywords: REST, rest, tail, restful, client, forDevelopers, forIntermediatesCopyright 2014, Pascal Dürsteler, <pascal @notionlab.ch >This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.org

Table of Contents

`EXT: tail 1 <#__RefHeading__5708_1738894311>`_

`Introduction 3 <#__RefHeading__5710_1738894311>`_

What does it do? 3

`Users manual 4 <#__RefHeading__467_413120346>`_

`Known problems 5 <#__RefHeading__31525_818911409>`_

Introduction

What does it do?

Tail is a minimalistic service library built on top of cUrl to interact with APIs. Since I wanted to keep it simple and based on the current features required, It currently just supports REST requests.

Tail does not (yet) use namespaces to be compatible with php5.2. It aims to integrate well with the TYPO3 core, that's why I havent just copied some existing framework.

Users manual

// Prepare and execute a GET request
$response = $client->get('path/to/resource')->send();

// Check the response
if ($response->isSuccess()) {
  // Get the JSON body as array
  $data = $response->responseBody()->fromJSON();

  // Or handle it by yourself:
  $raw_data = $response->responseBody()->raw();
} else {
  // Whops, something went wrong
  echo $response->status;

  // Display header for debugging purpose
  print_r($response->responseHeader()->data());
}

// You can also chain calls
$data = $client->get('path/to/resource.xml')->send()->responseBody()->fromXML();

// Add some custom headers for one request
$client->get('path/to/resource', array('X-My-Header: Custom'))->send();

// Doing a POST
$client->post('path/to/resource', array('key' => 'value'))->send();

// Of course, you can also PUT
$client->put('path/to/resource', attay('key' => 'value'))->send();

// or DELETE
$client->delete('path/to/resource')->send();

Known problems

Currently none. Please report bugs at the project's forge page.

Tail on forge.typo3.org