Embedly
, (*1)
Library for embed.ly APIs based on Guzzle 5., (*2)
API: emanueleminotto.github.io/Embedly, (*3)
Install
Install the Embedly library adding emanueleminotto/embedly
to your composer.json or from CLI:, (*4)
$ composer require emanueleminotto/embedly
Read more about the Composer installation here: getcomposer.org/doc/00-intro.md, (*5)
Usage
This library provides 3 API: embed.ly/docs/api., (*6)
Some APIs need an API key you can set in the constructor os using the setApiKey
method.
The second method of the constructor can be a Guzzle HTTP client to use as an alternative of the default one., (*7)
Embed
Options are available at http://embed.ly/docs/api/embed/arguments, (*8)
For this method the $api_key
can be null., (*9)
use EmanueleMinotto\Embedly\Client;
$client = new Client($api_key);
$embed = $client->oembed([
'url' => 'http://www.example.com/',
]);
// enumerated array containing
// arrays like $embed
$embeds = $client->oembed([
'urls' => [
'http://www.example.com/',
'http://www.google.com/'
]
]);
Options are available at http://embed.ly/docs/api/embed/arguments, (*10)
use EmanueleMinotto\Embedly\Client;
$client = new Client($api_key);
$extracted = $client->extract([
'url' => 'http://www.example.com/',
]);
// enumerated array containing
// arrays like $extracted
$extracteds = $client->oembed([
'urls' => [
'http://www.example.com/',
'http://www.google.com/'
]
]);
Display
The first argument can be NULL, crop
, resize
or fill
., (*11)
Options are available at, (*12)
- http://embed.ly/docs/api/display/endpoints/1/display
- http://embed.ly/docs/api/display/endpoints/1/display/crop
- http://embed.ly/docs/api/display/endpoints/1/display/resize
- http://embed.ly/docs/api/display/endpoints/1/display/fill
Currently the url
attribute is required., (*13)
use EmanueleMinotto\Embedly\Client;
$client = new Client($api_key);
$content = $client->display('resize', [
'url' => 'http://placehold.it/250x100',
'color' => '000',
'height' => 150,
'width' => 150,
]);
Twig Extension
In this library there's included a Twig extension to allow a simple integration with frameworks., (*14)
Functions prefix is: embedly_
, arguments are the same of the methods above., (*15)
{{ embedly_oembed({url: 'http://www.example.com'}).title }} {# Example Domain #}