图片库 / 媒体库
Picturae 网页厨房媒体库
0.2.1
2016-12-08 10:25 UTC
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-09-24 16:46:48 UTC
README
Picturae 网页厨房媒体库客户端
简介
媒体库客户端库发布,供第三方集成媒体库组件的服务端回退。这可以用于提高SEO排名(或)以及在不支持JavaScript的社交网络(如Facebook、Twitter)上的分享。
目前仅提供PHP实现,但可以作为其他语言(如JavaScript / C# / Java等)实现示例。
安装
composer require picturae/mediabank
使用方法
以下为客户端代码示例
$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) ]);
服务端回退
// 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 } }
网站地图
有关如何实现网站地图以改进搜索引擎可发现性的示例,请参阅网站地图示例
刷新
在API中刷新数据,仅当记录被修改且必须在前端直接显示时才使用API中的图片更新。
$client->refresh($entity, $id);