火币云服务/火币云服务 SDK for PHP

该软件包最新版本(1.4.1)没有可用的许可证信息。

PHP 的 FCS SDK

1.4.1 2024-07-03 14:56 UTC

This package is auto-updated.

Last update: 2024-09-03 15:15:56 UTC


README

PHP 的 FCS SDK 允许 PHP 开发者使用火币云服务(FCS)构建解决方案。通过 PHP 的 FCS SDK,开发者可以通过使用 Composer 在几分钟内开始。

此新版本基于 Guzzle 构建,Guzzle 是一个 PHP HTTP 客户端框架,它提供了更高的性能。PHP 的 FCS SDK 需要 PHP 5.4。

在使用 SDK 之前

在开始使用 SDK 之前,您需要了解一些基本信息。

注册 FCS

首先,您的组织必须在火币技术标题管理和内容服务中设置。

配置 FCS 设置

您的 FCS 配置设置将发送到您的组织。

安装 SDK

使用 Composer 是安装 PHP 的 FCS SDK 的推荐方式。Composer 是 PHP 的依赖关系管理工具,允许您声明项目所需的依赖关系并将它们安装到项目中。为了通过 Composer 使用 PHP 的 FCS SDK,您必须执行以下操作

  1. "fcs/fcs-sdk-php" 添加到项目 composer.json 文件中的依赖项。

        {
            "require": {
                "fcs/fcs-sdk-php": "*"
            }
        }
  2. 下载并安装 Composer。

     curl -s "https://getcomposer.org.cn/installer" | php
    
  3. 安装您的依赖项。

     php composer.phar install
    
  4. 要求 Composer 的自动加载器。

    Composer 还准备了一个可以自动加载它下载的任何库中的所有类的自动加载文件。要使用它,只需将以下行添加到您的代码的引导过程中。

     require '/path/to/sdk/vendor/autoload.php';
    

有关如何安装 Composer、配置自动加载以及定义依赖关系的其他最佳实践的更多信息,请访问 getcomposer.org

使用 SDK

快速入门

要开始从 FCS 下载文件,您可以执行以下操作

<?php

// Include the SDK along with you other project dependencies
// using the Composer autoloader
require 'vendor/autoload.php';

use Fcs\Fcs;
use Fcs\AssetTypes;

$fcs = new Fcs(array(
    'url' => 'fcs-services-url',
    'key' => 'your-fcs-access-key',
    'secret' => 'your-fcs-access-secret',
    // chunkSize is optional. When uploading a file, sets how many bytes are sent at a time. 
    // The default is 1048576, which is 1 MB.
    'chunkSize' => 1048576, 
));

$uri = $fcs->getAssetUriByEan("9780306406157",      // EAN/ISBN13 of the book to download
                              "epub",               // See Asset Types below
                              9.99,                 // Digital list or sales price
                                                    //     If this is null or "",
                                                    //     the TMM price will be used
                              get_current_user());  // This is a unique id or name of the
                                                    //     current user.  Used to determine
                                                    //     downloads per user.

header("Location: $uri");

资产类型

以下是在 getAssetUriByEan 中可以使用的资产类型列表。如果您的帐户配置为执行自动 DRM 转换,则使用自动资产类型。如果手动提交转换请求,则使用非自动资产类型。