basekit/php-api-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

basekit/php-api-client

最新稳定版本:4.0.0

Composer 安装命令:

composer require basekit/php-api-client

包简介

BaseKit PHP API client.

README 文档

README

A PHP client for BaseKit's REST API. This client will provide documentation of the services available from the BaseKit API, describing URIs, HTTP methods and input parameters.

Installation

The recommended way of including this package in your project is by using Composer. Add it to the require section of your project's composer.json.

composer require basekit/php-api-client

Usage

use BaseKit\Api\AuthType;
use BaseKit\Api\ClientFactory;

$client = ClientFactory::create(
    [
        'base_uri' => 'http://api.testing.com',
        'username' => 'foo',
        'password' => 'bar',
    ],
    AuthType::BASIC, // defaults to basic auth
);

$createSite = $client->getCommand(
    'CreateSite',
    [
        'accountHolderRef' => 123,
        'brandRef' => 789,
        'domain' => 'test.example.org',
    ]
);

$client->execute($createSite);

A more detailed example script is available here including account and site creation and populating a site with content using the API.

Testing

Feed an optional handler into the config of clientFactory to control the responses from the http client.

use BaseKit\Api\ClientFactory;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Psr7\Response;

$client = ClientFactory::create([
    'base_uri' => 'https://api.testing.com',
    'username' => 'foo',
    'password' => 'bar',
    'handler' => HandlerStack::create(
        new MockHandler([
            new Response(404, [], '"Hello, World! This is a test response."'),
        ])
    ) ,
]);

$createSite = $client->getCommand(
    'CreateSite',
    [
        'accountHolderRef' => 123,
        'brandRef' => 789,
        'domain' => 'test.example.org',
    ]
);

$client->execute($createSite); // Throws a 404 CommandClientException

License

This software is released under the MIT License.

统计信息

  • 总下载量: 4.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 24
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-11-26