|
Project Information
|
A library originally written for RockForums.Co, it's add oEmbed to your project. oEmbed allows you to fetch html code from certain site such as YouTube, the html code can either be videos, images or other kinds of data. ProvidersProviders currently supported are
How to useEasy Method// Include or require file at beginning.
require_once 'oembedder.class.php';
// Create oEmbedder object.
$oembed = new oEmbedder();
// (Optional) Enable Discovery, it's disabled by default.
$oembed->enableDiscovery();
// (Optional) Embedly API Key
$oembed->setEmbedlyKey('key');
// Parse url
$oembed->parseUrl('http://www.youtube.com/watch?v=Bdlu1o8Z-ik&feature=feedu');
// Validation Check
if($oembed->isValid()) {
// Fetch Code
echo $oembed->fetchCode();
}Advanced Method// Include or require file at beginning.
require_once 'oembedder.class.php';
// Create oEmbedder object.
$oembed = new oEmbedder();
// (Optional) Enable Discovery, it's disabled by default.
$oembed->enableDiscovery();
// (Optional) Embedly API Key
$oembed->setEmbedlyKey('key');
// Parse url
$oembed->parseUrl('http://www.youtube.com/watch?v=Bdlu1o8Z-ik&feature=feedu');
// Validation Check
if($oembed->isValid()) {
// Get Meta
$meta = $oembed->getMeta();
// Sanity Check
if(isset($meta['type'])) {
//Check if video
if($meta['type'] == 'video') {
//Output
echo $meta['html'];
}
}
}If you are familier with oEmbed, you will probably know what in the $meta array. |