Skip to content

@rmccue /simplepie-gametrailers.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
// Extend SimplePie to retrieve the embed data from a GameTrailers.com feed
// Load SimplePie
include('simplepie.class.php');
// Define the GameTrailers namespace
define("SIMPLE_NAMESPACE_GAMETRAILERS", "http://www.gametrailers.com/rssexplained.php");
// Extend SimplePie_Item with our own class
class SimplePie_Item_Gametrailers extends SimplePie_Item
{
// Make sure we pass everything through
function __construct($feed, $data) {
parent::__construct($feed, $data);
}
// Use SimplePie_Item's API to get the embed code
function get_embed_id()
{
$data = $this->get_item_tags(SIMPLE_NAMESPACE_GAMETRAILERS, 'fileType');
return $data[0]['child']['']['embedcode'][0]['data'];
}
}
// ...
// Example of how to use.
$sp = new SimplePie();
$sp->set_item_class('SimplePie_Item_Gametrailers');
$sp->set_feed_url('http://www.gametrailers.com/rssgenerate.php?s1=&favplats[pc]=pc&vidformat[flv]=on&type[gameplay]=on&embed=on&quality[sd]=on&agegate[no]=on&orderby=newest&limit=20');
$sp->init();
foreach($sp->get_items() as $item) {
echo $item->get_title() . ' - ';
var_dump($item->get_embed_id());
echo '<br />';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.