I've got a nice little web app working that brings down playlists and videos from YouTube using the API. However, YouTube seems to fire back the playlists in the wrong order.
Any idea how I can do that?
Here is my very simple PHP code that does everything I need it to do (apart from date ordering)
<?php
// set feed URL
$feedURL = 'http://gdata.youtube.com/feeds/api/users/popcorncomedy/playlists?v=2';
// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);
?>
<div class="container">
<h1><?php echo $sxml->title; ?></h1>
<?php
// iterate over entries in feed
foreach ($sxml->entry as $entry) {
// get nodes in media: namespace for media information
$media = $entry->children('http://search.yahoo.com/mrss/');
// get <yt:duration> node for video length
$yt = $entry->children('http://gdata.youtube.com/schemas/2007');
?>
<a href="videos.php?playlist=<?php echo $yt->playlistId; ?>"><div class="item">
<span class="title"><?php echo $entry->title; ?></span><br /><br />
<span class="summary"><?php echo $entry->summary; ?></span>
</div></a>
<?php
} // closes the loop
?>
The XML element that contains the date is called: published in the date format: 2010-03-03T17:37:34.000Z
Any thoughts on how to achieve this simply?
I can't find a function within the API itself that orders content for you.