wordproof/api-client

此包已被弃用且不再维护。未建议替代包。

WordProof API 客户端

0.3.0 2021-03-22 12:37 UTC

This package is auto-updated.

Last update: 2022-06-24 10:22:26 UTC


README

要求

  • PHP 5.6.20 | ^7.0 | ^8.0
  • cURL 扩展
  • JSON 扩展

安装

composer require wordproof/api-client

用法


use WordProof\ApiClient\WordProofApi;

$wordproof = new WordProofApi('SOMEAPIKEY');

$response = $wordproof->timestamp()->post([
            'foo' => 'bar',
            'another_foo' => 'another_bar',
        ]);

您可以指定一些选项

use WordProof\ApiClient\WordProofApi;

$wordproof = new WordProofApi('SOMEAPIKEY');

$response = $wordproof->withOptions([
                'endpoint' => 'http://endpoint.com'
            ])
            ->timestamp()->post([
                'foo' => 'bar',
                'another_foo' => 'another_bar',
            ]);

您可以使用自己的 PSR 请求和 StreamFactory 实现

use WordProof\ApiClient\WordProofApi;
use Laminas\Diactoros\Request;
use Laminas\Diactoros\StreamFactory;

$wordproof = new WordProofApi('SOMEAPIKEY');

$request = new Request(
        'http://endpoint.com',
        'POST',
        (new StreamFactory())->createStream(json_encode([
            'foo' => 'bar',
            'another_foo' => 'another_bar',
        ])),
        ['Content-Type' => 'application/json']
);

$response = $wordproof->sendRequest($request);