Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

wordproof/api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordProof API client

Requirements

  • PHP 5.6.20 | ^7.0 | ^8.0
  • cURL extension
  • JSON extension

Install

composer require wordproof/api-client

Usage


use WordProof\ApiClient\WordProofApi;

$wordproof = new WordProofApi('SOMEAPIKEY');

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

You can specify some options:

use WordProof\ApiClient\WordProofApi;

$wordproof = new WordProofApi('SOMEAPIKEY');

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

You can use your own PSR Request and StreamFactory implementations:

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);