PHP code example of basekit / php-api-client
1. Go to this page and download the library: Download basekit/php-api-client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
basekit / php-api-client example snippets
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);
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
bash
composer