定制 fastpix/sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fastpix/sdk

Composer 安装命令:

composer require fastpix/sdk

包简介

FastPix PHP SDK for media, live streaming, playlists, analytics, and signing keys

README 文档

README

Developer-friendly & type-safe PHP SDK for the FastPix platform API

Introduction

The FastPix PHP SDK simplifies integration with the FastPix platform. It provides a clean, PHP 8+ interface for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, on‑demand content, playlists, video analytics, and signing keys for secure access and token management. It is intended for use with PHP 8.2 and above.

Prerequisites

Environment and Version Support

Requirement Version Description
PHP 8.2+ Core runtime environment
Composer Latest Package manager for dependencies
Internet Required API communication and authentication

Pro Tip: We recommend using PHP 8.3+ for optimal performance and the latest language features.

Getting Started with FastPix

To get started with the FastPix PHP SDK, ensure you have the following:

  • The FastPix APIs are authenticated using a Username and a Password. You must generate these credentials to use the SDK.
  • Follow the steps in the Authentication with Basic Auth guide to obtain your credentials.

Environment Variables (Optional)

Configure your FastPix credentials using environment variables for enhanced security and convenience:

# Set your FastPix credentials
export FASTPIX_USERNAME="your-access-token"
export FASTPIX_PASSWORD="your-secret-key"

Security Note: Never commit your credentials to version control. Use environment variables or secure credential management systems.

Table of Contents

Setup

Installation

The SDK relies on Composer to manage its dependencies.

Add the SDK to your project:

{
    "require": {
        "fastpix/sdk": "*"
    }
}

Then run:

composer update

If you host the package in a private repository, add the repository to your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/FastPix/fastpix-php.git"
        }
    ],
    "require": {
        "fastpix/sdk": "*"
    }
}

Imports

Use the SDK via Composer’s autoload and the FastPix namespaces:

<?php

require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;
use FastPix\Sdk\Models\Operations;

Initialization

Initialize the FastPix SDK with your credentials:

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

$sdk = Sdk\Fastpixsdk::builder()
    ->setSecurity(
        new Components\Security(
            username: 'your-access-token',
            password: 'your-secret-key',
        )
    )
    ->build();

Or using environment variables:

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

$username = getenv('FASTPIX_USERNAME') ?: 'your-access-token';
$password = getenv('FASTPIX_PASSWORD') ?: 'your-secret-key';

$sdk = Sdk\Fastpixsdk::builder()
    ->setSecurity(
        new Components\Security(
            username: $username,
            password: $password,
        )
    )
    ->build();

Example Usage

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

try {
    $sdk = Sdk\Fastpixsdk::builder()
        ->setSecurity(
            new Components\Security(
                username: 'your-access-token',
                password: 'your-secret-key',
            )
        )
        ->build();

    $request = new Components\CreateMediaRequest(
        inputs: [
            new Components\PullVideoInput(),
        ],
        metadata: [
            'key1' => 'value1',
        ],
    );

    $response = $sdk->inputVideo->createMedia(
    request: $request
);

    if ($response->statusCode >= 200 && $response->statusCode < 300) {
        $rawBody = (string) $response->rawResponse->getBody();
        $decoded = json_decode($rawBody, true);
        echo ($decoded !== null ? json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) : $rawBody) . "\n";
    } else {
        $errorPayload = $response->defaultError ?? $response->error ?? null;
        if ($errorPayload !== null) {
            $errorResponse = json_decode(json_encode($errorPayload), true);
            echo json_encode($errorResponse, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
        } else {
            echo json_encode(['message' => 'No response data'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
        }
    }
} catch (\Exception $e) {
    // Extract API error response
    $errorBody = null;
    if (property_exists($e, 'body') && property_exists($e, 'statusCode')) {
        $body = $e->body;
        $errorBody = json_decode($body, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            $errorBody = $body;
        }
    } elseif (method_exists($e, 'getResponse')) {
        $response = $e->getResponse();
        if ($response !== null) {
            $body = (string)$response->getBody();
            $errorBody = json_decode($body, true);
            if (json_last_error() !== JSON_ERROR_NONE) {
                $errorBody = $body;
            }
        }
    }
    
    // Output API error response
    if ($errorBody !== null) {
        echo json_encode($errorBody, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
    } else {
        echo json_encode(['error' => $e->getMessage()], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
    }
    exit(1);
}

Available Resources and Operations

Comprehensive PHP SDK for FastPix platform integration with full API coverage.

Media API

Upload, manage, and transform video content with comprehensive media management capabilities.

For detailed documentation, see FastPix Video on Demand Overview.

Input Video

Manage Videos

Playback

Playlist

Signing Keys

DRM Configurations

Live API

Stream, manage, and transform live video content with real-time broadcasting capabilities.

For detailed documentation, see FastPix Live Stream Overview.

Start Live Stream

  • Create Stream - Initialize new live streaming session with DVR mode support

Manage Live Stream

Live Playback

Simulcast Stream

Video Data API

Monitor video performance and quality with comprehensive analytics and real-time metrics.

For detailed documentation, see FastPix Video Data Overview.

Metrics

Views

Dimensions

Errors

  • List Errors - List playback errors for diagnostics and monitoring

Transformations

Transform and enhance your video content with powerful AI and editing capabilities.

In-Video AI Features

Enhance video content with AI-powered features including moderation, summarization, and intelligent categorization.

Media Clips

Subtitles

Media Tracks

Access Control

Format Support

Error Handling

All operations return a response object or throw an exception. By default, an API error will raise an Errors\APIException (or operation-specific error types).

Property Type Description
$message string The error message
$statusCode int The HTTP status code
$rawResponse ?\Psr\Http\Message\ResponseInterface The raw HTTP response
$body string The response content

Example

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

$sdk = Sdk\Fastpixsdk::builder()
    ->setSecurity(
        new Components\Security(
            username: 'your-access-token',
            password: 'your-secret-key',
        )
    )
    ->build();

try {
    $request = new Components\CreateMediaRequest(
        inputs: [new Components\PullVideoInput(url: 'https://static.fastpix.com/fp-sample-video.mp4')],
        metadata: ['key1' => 'value1'],
    );

    $response = $sdk->inputVideo->createMedia(request: $request);

    if ($response->createMediaSuccessResponse !== null) {
        $rawBody = (string) $response->rawResponse->getBody();
        $decoded = json_decode($rawBody, true);
        echo json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    }
} catch (\FastPix\Sdk\Models\Errors\APIException $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "Status: " . $e->statusCode . "\n";
    echo "Body: " . $e->body . "\n";
}

Refer to the Errors tables in each operation’s SDK doc for possible exception types.

Server Selection

Override Server URL Per-Client

Override the default server by passing a URL when building the SDK:

<?php

declare(strict_types=1);

require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

$sdk = Sdk\Fastpixsdk::builder()
    ->setServerUrl('https://api.fastpix.com/v1/')
    ->setSecurity(
        new Components\Security(
            username: 'your-access-token',
            password: 'your-secret-key',
        )
    )
    ->build();

Development

This PHP SDK is programmatically generated from our API specifications. Any manual modifications to internal files will be overwritten during subsequent generation cycles.

We value community contributions and feedback. Feel free to submit pull requests or open issues with your suggestions, and we'll do our best to include them in future releases.

Detailed Usage

For comprehensive understanding of each API's functionality, including detailed request and response specifications, parameter descriptions, and additional examples, please refer to the FastPix API Reference.

The API reference offers complete documentation for all available endpoints and features, enabling developers to integrate and leverage FastPix APIs effectively.

fastpix/sdk 适用场景与选型建议

fastpix/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 fastpix/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fastpix/sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 fastpix/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-22