Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dhrrgn/9356528 to your computer and use it in GitHub Desktop.
Save dhrrgn/9356528 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