1. Go to this page and download the library: Download bajzany/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/ */
bajzany / api-client example snippets
namespace Bajzany\ApiClient\Example;
use Bajzany\ApiClient\Model\EndPoint;
use Bajzany\ApiClient\Provider;
use Bajzany\ApiClient\Response;
class UpdateUserApi extends EndPoint
{
const METHOD = Provider::METHOD_POST;
/**
* @var int
*/
private $userId;
/**
* @var array
*/
private $data;
public function __construct(int $userId, array $data)
{
$this->userId = $userId;
$this->data = $data;
}
/**
* @return string
*/
public function getUrl(): string
{
return "http://crm.d/test/user-update/{$this->userId}";
}
/**
* @param Provider $provider
* @return mixed
* @internal
*/
public function processRawRequest(Provider $provider): array
{
return $this->data;
}
/**
* @param Provider $provider
* @return Response|mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function execute(Provider $provider)
{
return parent::execute($provider);
}
}
/** @var Provider @inject */
public $provider;
$updateUserApi = new UpdateUserApi($userId, [$myData]);
$response = $updateUserApi->execute($this->provider);