1. Go to this page and download the library: Download swisnl/json-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/ */
swisnl / json-api-client example snippets
php
use Swis\JsonApi\Client\DocumentClient;
$client = DocumentClient::create();
$document = $client->get('https://cms.contentacms.io/api/recipes');
/** @var \Swis\JsonApi\Client\Collection&\Swis\JsonApi\Client\Item[] $collection */
$collection = $document->getData();
foreach ($collection as $item) {
// Do stuff with the items
}
php
use Swis\JsonApi\Client\Item;
class AuthorItem extends Item
{
protected $type = 'author';
public function blogs()
{
return $this->hasMany(BlogItem::class);
}
}
class BlogItem extends Item
{
protected $type = 'blog';
public function author()
{
return $this->hasOne(AuthorItem::class);
}
}