picturae / mediabank
Picturae webkitchen mediabank
Installs: 3 339
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 24
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- phpmd/phpmd: ^2.2
- phpunit/phpunit: ^4.8
- satooshi/php-coveralls: ^0.6.1
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-10-24 17:00:55 UTC
README
Picturae webkitchen mediabank client
Introduction
The mediabank client library is released for third parties who want to integrate a serverside fallback for the mediabank component. This can be used to improve SEO ranking (or) and sharing on social networks as facebook, twitter which do not support javascript.
Currently there is only a PHP implementation but it can serve as an example for implementation in other languages as Javascript / C# / Java etc.
Installation
composer require picturae/mediabank
Usage
See below the code example for the client
$client = new \Picturae\Mediabank\Client('api-key'); // Get a record $media = $client->getMedia($id); // Get a result list // all parameters are optional $result = $client->search([ 'q' => 'something', // search query 'rows' => 100, // amount of rows to return 'page' => 1, // page to return 'facetFields' => [ // facet's to return 'search_s_place' ], 'fq' => [ 'search_s_place: "Amsterdam"' // apply filter query ], 'sort' => 'search_s_place asc' // sort result set (default by relevance) ]);
Serverside fallback
// If you do not provide a url the current url is used $url = new \Picturae\Mediabank\URL(); // Check if we are on a permalink if ($url->isDetail()) { // Get the id for the record from the URL $id = $url->getUUID(); // Instantiate the client with your API key $client = new \Picturae\Mediabank\Client('api-key'); // Fetch the record $media = $client->getMedia($id); // Check if the record is returned if (!empty($media) { // Add your logic for the fallback // e.g add opengraph tags for facebook / twitter // or provide a html fallback } }
Sitemap
For an example how to implement a sitemap to improve discoverability for search engines look at the sitemap example
Refresh
Refresh data in the API, updates the image in the API only use sparingly when a record is modified and must be shown on the frontend directly.
$client->refresh($entity, $id);