Home

Awesome

Embedly

Build Status SensioLabs Insight Coverage Status Scrutinizer Code Quality Total Downloads

Library for embed.ly APIs based on Guzzle 5.

API: emanueleminotto.github.io/Embedly

Install

Install the Embedly library adding emanueleminotto/embedly to your composer.json or from CLI:

$ composer require emanueleminotto/embedly

Read more about the Composer installation here: getcomposer.org/doc/00-intro.md

Usage

This library provides 3 API: embed.ly/docs/api.

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.

Embed

Options are available at http://embed.ly/docs/api/embed/arguments

For this method the $api_key can be null.

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/'
    ]
]);

Extract

Options are available at http://embed.ly/docs/api/embed/arguments

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.

Options are available at

Currently the url attribute is required.

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.

Functions prefix is: embedly_, arguments are the same of the methods above.

{{ embedly_oembed({url: 'http://www.example.com'}).title }} {# Example Domain #}