Skip to content

Instantly share code, notes, and snippets.

@harikt
Forked from dhrrgn/oembed.php
Created March 5, 2014 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/9359734 to your computer and use it in GitHub Desktop.
Save harikt/9359734 to your computer and use it in GitHub Desktop.
<?php
$url = 'https://twitter.com/dhrrgn/status/440968615697715200';
$embedly = new Embedly\Embedly([
'key' => getenv('EMBEDLY_KEY'),
]);
if (preg_match('#https?://(?:www.)?twitter.com/[^/]+/status/([0-9]+)#i', $url, $match)) {
$oembed = json_decode(file_get_contents('https://api.twitter.com/1/statuses/oembed.json?id='.$match[1]), true);
} else {
$oembed = (array) $embedly->oembed($url);
}
// Do something with $oembed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment