-
-
Save harikt/9359734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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