1. Go to this page and download the library: Download bedita/php-sdk 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/ */
$response = (array)$client->authenticate('my-username', 'my-password');
if (!empty($response['meta'])) {
$client->setupTokens($response['meta']);
}
// get documents
$response = (array)$client->getObjects('documents'); // argument passed is a string $type
// get documents using a filter
$query = [
'filter' => ['parent' => 'some-parent-id'],
];
$response = (array)$client->getObjects('documents', $query); // arguments passed are string $type and array $query
// get documents using a filter and more query options
//
// get document 17823
$response = (array)$client->getObject(17823, 'documents'); // arguments passed are int|string $id, string $type
// get document 17823, english version, including related data by relations "has_media" and "part_of"
$query = [
'lang' => 'en',
'tring $id, string $type
// get API status
$response = (array)$client->get('/status'); // argument passed is string $path
// get API home info
$response = (array)$client->get('/home'); // argument passed is string $path
// get a list of documents
$query = [
'filter' => ['parent' => 'some-parent-id'],
];
$response = (array)$client->get('/documents', $query); // arguments passed are string $path and array $query
// get a stream by id
$response = (array)$client->get('/streams/the-stream-id'); // argument passed is string $path
// get subfolders for a folder with ID 888
$query = [
'filter' => ['type' => 'folders'],
];
$subfolders = $client->getRelated(888, 'folders', 'children', $query); // arguments passed are int|string $id, string $type, string $relation, array $query
// get children (all types) inside a folder with unique name 'my-folder-uname'
$children = $client->getRelated('my-folder-uname', 'folders', 'children'); // arguments passed are int|string $id, string $type, string $relation
// save a new document
$data = [
'title' => 'My new doc',
'status' => 'on',
];
$response = (array)$client->save('documents', $data); // arguments passed are string $type, array $data
// retrocompatibility version with saveObject, deprecated
$response = (array)$client->saveObject('documents', $data); // arguments passed are string $type, array $data
// save an existing document
$data = [
'id' => 999,
'title' => 'My new doc, changed title',
];
$response = (array)$client->save('documents', $data); // arguments passed are string $type, array $data
// retrocompatibility version with saveObject, deprecated
$response = (array)$client->saveObject('documents', $data); // arguments passed are string $type, array $data
// save a new document
$data = [
'type' => 'documents',
'attributes' => [
'title' => 'My doc',
'status' => 'on',
],
];
$response = (array)$client->post('/documents', $data); // arguments passed are string $path, array $data
// save an existing document
$data = [
'type' => 'documents',
'attributes' => [
'title' => 'My doc',
'status' => 'on',
],
];
$response = (array)$client->post('/documents/999', $data); // arguments passed are string $path, array $data
// delete document by ID 99999
$response = $client->delete('/documents/99999'); // argument passed is string $path
// delete document by ID 99999 and type documents
$response = $client->deleteObject(99999, 'documents'); // arguments passed are string|int $id, string $type
// delete multiple
$response = $client->deleteObjects([999991, 999992, 999993], 'documents');
// save a document and add related objects, in this example a "see_also" relation between documents and documents is involved
$document = $client->save('documents', ['title' => 'My new doc']);
$relatedData = [
[
'id' => 9999, // another doc id
'type' => 'documents',
],
];
$client->addRelated($document['data']['id'], 'documents', 'see_also', $relatedData); // arguments passed are int|string $id, string $type, string $relation, array $relationData
// replace related objects, in this example a "see_also" relation between document 8888 and document 9999
$relatedData = [
[
'id' => 9999,
'type' => 'documents',
],
];
$client->replaceRelated(8888, 'documents', 'see_also', $relatedData); // arguments passed are int|string $id, string $type, string $relation, array $relationData
// remove related data, in this example a "see_also" relation between document 8888 and document 9999
$relatedData = [
[
'id' => 9999,
'type' => 'documents',
],
];
$client->removeRelated(8888, 'documents', 'see_also', $relatedData); // arguments passed are int|string $id, string $type, string $relation, array $relationData
// get thumbnail for media 123 => GET /media/thumbs/123
$client->thumbs(123);
// get thumbnail for media 123 with a preset => GET /media/thumbs/123&preset=glide
$client->thumbs(123, ['preset' => 'glide']);
// get thumbnail for multiple media => GET /media/thumbs?ids=123,124,125
$client->thumbs(null, ['ids' => '123,124,125']);
// get thumbnail for multiple media with a preset => GET /media/thumbs?ids=123,124,125&preset=async
$client->thumbs(null, ['ids' => '123,124,125', 'preset' => 'async']);
// get thumbnail media 123 with specific options (these options could be not available... just set in preset(s)) => GET /media/thumbs/123/options[w]=100&options[h]=80&options[fm]=jpg
$client->thumbs(123, ['options' => ['w' => 100, 'h' => 80, 'fm' => 'jpg']]);
// get schema of users => GET /model/schema/users
$schema = $client->schema('users');
// get relation data of relation see_also => GET /model/relations/see_also
$schema = $client->relationData('see_also');
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.