otoyinc/xio-php

X.IO integration library for PHP

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

1.0.0 2015-01-08 22:56 UTC

This package is not auto-updated.

Last update: 2024-04-27 14:38:36 UTC


README

Author: [Mike Christopher] (mike.christopher (a) otoy (.) c�om)

Company: OTOY

Version: 1.0.0

Date: 2015-01-08

Repository: http://github.com/otoyinc/xio-php/

Parts of this library are based on http://github.com/twilio/twilio-php and http://github.com/zencoder/zencoder-php

For more details on the X.IO API requirements visit http://docs.x.io/v1/docs

To start working with the library, create a new instance of the Services_XIO class, passing your API Key ID as the first parameter and API Secret Key as the second.

$xio = new Services_XIO('R45KU9BJWTKM4ATGZNKF29LJZ', 'F2kiGEZuhv7D7AEujAiwgLKVjZjP28pa0P96pbiw');

Once you have created the object, you can use it to interact with the API. For full information, see the Documentation folder, but here is a quick overview of some of the functions that can be called:

$xio->streams->create($array);
$xio->streams->details($stream_id);
$xio->streams->cancel($stream_id);

Any errors will throw a Services_XIO_Exception. You can call getErrors() on an exception and it will return any errors received from the X.IO API.

STARTING A STREAM

The Services_XIO_Streams object creates an stream session using cURL to send JSON formatted parameters to X.IO's API.

Step 1

Visit the API documentation and build a sample request.

Step 2

Copy the successful JSON string, starting with the first curly brace "{", and pass it as the parameters for a new Services_XIO_Streams object. Execute the script on your server to test that it works.

Example

<?php

// Make sure this points to a copy of XIO.php on the same server as this script.
require_once('Services/XIO.php');

$stream = null;
try {
  // Initialize the Services_XIO class
  $xio = new Services_XIO('R45KU9BJWTKM4ATGZNKF29LJZ', 'F2kiGEZuhv7D7AEujAiwgLKVjZjP28pa0P96pbiw');

  // New Encoding Job
  $stream = $xio->streams->create(
    array(
      "application_id" => "7cd9272c77ef44aeb460a70de434067a",
      "version_id" => "980a84ff564b4c459cc5a658fd3fa838"
    )
  );

  // Success if we got here
  echo "w00t! \n\n";
  echo "Stream ID: ".$stream->id."\n";
  echo "Application name: ".$stream->application->name."\n";
} catch (Services_XIO_Exception $e) {
  // If were here, an error occured
  echo "Fail :(\n\n";
  echo "Errors:\n";
  echo $e->getErrors()->error."\n\n";
  echo "Full exception dump:\n\n";
  print_r($e);
}

echo "\nAll Stream Attributes:\n";
var_dump($stream);

?>

VERSIONS

Version 1.0.0   - 2015-01-08    Initial release, supports streams.