otoyinc / xio-php
PHP 的 X.IO 集成库
1.0.0
2015-01-08 22:56 UTC
Requires
- php: >=5.2.0
This package is not auto-updated.
Last update: 2024-09-28 16:46:40 UTC
README
作者:[Mike Christopher] (mike.christopher (a) otoy (.) c�om)
公司: OTOY
版本:1.0.0
日期:2015-01-08
仓库: http://github.com/otoyinc/xio-php/
此库的部分代码基于 http://github.com/twilio/twilio-php 和 http://github.com/zencoder/zencoder-php
有关 X.IO API 要求的更多详细信息,请访问 http://docs.x.io/v1/docs
要开始使用此库,创建 Services_XIO 类的新实例,将 API 密钥 ID 作为第一个参数,将 API 密钥作为第二个参数传递。
$xio = new Services_XIO('R45KU9BJWTKM4ATGZNKF29LJZ', 'F2kiGEZuhv7D7AEujAiwgLKVjZjP28pa0P96pbiw');
创建对象后,您可以使用它与 API 进行交互。有关完整信息,请参阅文档文件夹,但以下是一些可以调用的函数的快速概述
$xio->streams->create($array); $xio->streams->details($stream_id); $xio->streams->cancel($stream_id);
任何错误都会抛出 Services_XIO_Exception。您可以在异常上调用 getErrors(),它将返回从 X.IO API 收到的任何错误。
开始流
Services_XIO_Streams 对象使用 cURL 创建流会话,向 X.IO 的 API 发送格式为 JSON 的参数。
步骤 1
访问 API 文档 并构建一个示例请求。
步骤 2
复制成功的 JSON 字符串,从第一个花括号 "{ " 开始,并将其作为新 Services_XIO_Streams 对象的参数传递。在您的服务器上执行脚本以测试它是否正常工作。
示例
<?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); ?>
版本
Version 1.0.0 - 2015-01-08 Initial release, supports streams.