fourkitchens/picsart-api-client

dev-main 2023-05-09 19:16 UTC

This package is auto-updated.

Last update: 2024-09-09 22:53:06 UTC


README

简介

Picsart Image Tools API是一个简单的HTTP接口。结果通常是输出图像的URL。要开始使用,首先你需要获取API密钥。以下是一些示例代码,可以帮助你轻松入门。参考文档提供了更多关于可调整的可用参数的信息。## 示例运行curl -X POST \\ 'https://api.picsart.io/tools/1.0/removebg' \\ -H 'x-picsart-api-key: APIKEYHERE' \\ -F 'output_type=cutout' \\ -F 'image_url=https://cdn140.picsart.com/13902645939997000779.jpg'## 服务器演示环境已删除(https://api.picsart.io/tools/demo/)。我们建议您使用新的生产环境(https://api.picsart.io/tools/1.0/)。如果您发现任何问题,请与我们联系。## API密钥为了试用我们的服务,您需要* 创建一个账户,* 在我的应用下创建一个应用* 并获取用于授权的API密钥。您可以在快速入门中找到更多关于此过程的详细信息。## 输入文件支持JPG、PNG和WEBP类型的输入图像。输入图像文件大小最大为100 MB。上传的图像文件的引用将在24小时内有效。## 输出格式您可以通过格式参数请求三种格式之一:JPG、PNG、WEBP。结果文件将在24小时内可用。## 速率限制在演示运行期间,用户每月可以处理多达100个请求。当达到速率限制时,API将返回429代码,并带有以下信息: { \"fault\": { \"faultstring\": \"速率限制配额违规。配额限制超出。标识符 : _default\", \"detail\": { \"errorcode\": \"policies.ratelimit.QuotaViolation\" } } } ## 认证应通过提供的API密钥进行认证。API密钥可以作为头信息发送: curl 'https://api.picsart.io/tools/1.0/effects' -H 'x-picsart-api-key: APIKEY' 开发者指南

此PHP包由Swagger Codegen项目自动生成

  • API版本:2.0
  • 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen

要求

PHP 5.5及更高版本

安装和用法

Composer

要通过Composer安装绑定,请将以下内容添加到composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/git_user_id/git_repo_id.git"
    }
  ],
  "require": {
    "git_user_id/git_repo_id": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请按照安装程序进行操作,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: apiKey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-Picsart-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-Picsart-API-Key', 'Bearer');

$apiInstance = new Swagger\Client\Api\AdjustApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->adjustPost();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AdjustApi->adjustPost: ', $e->getMessage(), PHP_EOL;
}

// Configure API key authorization: apiKey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('X-Picsart-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-Picsart-API-Key', 'Bearer');

$apiInstance = new Swagger\Client\Api\AdjustApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->editPost();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AdjustApi->editPost: ', $e->getMessage(), PHP_EOL;
}
?>

API端点文档

所有URI相对于https://api.picsart.io/tools/1.0

模型文档

授权文档

apiKey

  • 类型: API密钥
  • API密钥参数名: X-Picsart-API-Key
  • 位置: HTTP头

作者