PHP code example of meriksk / fotkomotko-php-sdk
1. Go to this page and download the library: Download meriksk/fotkomotko-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/ */
meriksk / fotkomotko-php-sdk example snippets
// once '/path/to/FotkomotkoClient/src/autoload.php';
// alternatively, use composer
$options = array(
'base_url' => 'http://url-to-fotkomotko/api',
'username' => 'your_username',
'password' => 'your_password',
);
$api = new \Fotkomotko\Api($options);
$options = [
'base_url' => 'http://url-to-fotkomotko/api',
'username' => 'your_username',
'password' => 'your_password',
];
$api = new \Fotkomotko\Api($options);
// Get a single album (find by Id)
$response = $api->getAlbum(1);
if ($response->success) {
echo '<p>Album: <strong>' . $response->data['title'] . '</strong></p>';
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}
// Get a single album (find by album title)
$response = $api->getAlbum('album-title');
if ($response->success) {
echo '<p>Album: <strong>' . $response->data['title'] . '</strong></p>';
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}
// Get list of albums
$response = $api
->visibility(\Fotkomotko\Api::VISIBILITY_PUBLIC)
->continents(\Fotkomotko\Api::EUROPE)
->years(2014)
->sort('-date')
->getAlbums(array(
'tags' => 'europe'
));
if ($response->success) {
foreach($response->data['items'] as $album { ... }
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}
// Get single photo
$response = $api->getPhoto(1);
if ($response->success) {
echo '<p>Photo: <strong>' . $response->data['title'] . '</strong></p>';
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}
// Get list of photos from a single album
$response = $api->albums(1)->getAlbums($params);
if ($response->success) {
foreach($response->data['items'] as $photo { ... }
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}
// Get single collection
$response = $api->getCollection(1);
if ($response->success) {
echo '<p>Collection: <strong>' . $response->data['title'] . '</strong></p>';
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}
// Get list of collection
$response = $api->getCollections(array(
'albums' => true,
'coverPhoto' => true,
));
if ($response->success) {
foreach($response->data['items'] as $collection { ... }
} else {
echo '<p>Error: <strong>' . $response->code . ': ' . $response->message . '</strong></p>';
}