This package is abandoned and no longer maintained. The author suggests using the embed/embed package instead.

Prototype to extract basic embed properties from 3rd party content

0.3.3 2021-02-09 22:23 UTC

This package is auto-updated.

Last update: 2021-06-01 20:02:11 UTC


Simple class to extract properties for embedding 3rd party resources supporting OEmbed protocol.

Currently we support only resources with Discovery links


composer require samayamx/embed-extractor


  • cURL to get resources
  • ext-json to extract data from oembed response


You can use this simple service in a controller without too much hassle:

use Samaya\Embed\Extract;

$extractor = new Extract(

Route::get('/embed', function (Request $request) use ($extractor) {
    $url = $request->get('url');
    try {
        $image = $extractor->getImage($url);
        $html = $extractor->getHtml($url);

        return response()->json(compact('url', 'html', 'image'));
    } catch (\DomainException $domainException) {
        // for Facebook "OpenGraph" errors
        return response()->json(
          ['message' => $domainException->getMessage()],
    } catch (\Exception $exception) {
        // handle other exceptions as well
        return response(

If you prefer, you can use the provided Laravel facade or configuration to provide the service with required parameters:

use Samaya\Embed\Extract;

// injected into the action handler:
Route::get('/embed', function (Extract $extractor, Request $request) {
    // ...

use Samaya\Embed\OEmbedExtract;

// using the facade
$image = OEmbedExtract::getImage($url);
$html = OEmbedExtract::getHtml($url);

configuration with Laravel

To use the provided facade or automatic service instantiation, you provide the required secrets in environment and/or published configuration.

See .env.example for an example of the default environment variables.

Publish the configuration if you need to tweak the identifiers to avoid collision with another package:

php artisan vendor:publish --provider=Samaya\\Embed\\OEmbedExtractProvider --tag=config


  • Facebook
  • Vimeo
  • Youtube
  • Samaya Share