Created
September 14, 2014 18:33
-
-
Save dsager/4b819b27ca751bfc8a59 to your computer and use it in GitHub Desktop.
Small script to fetch a list of a user's Gists on GitHub
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 | |
/** | |
* Small script to fetch a list of a user's Gists on GitHub | |
* | |
* Copyright (c) 2014 Daniel Sager | |
* License: MIT, https://gist.github.com/dsager/0edcbf806b5b86e78455#file-2014 | |
*/ | |
date_default_timezone_set('UTC'); | |
$url = 'https://gist.github.com/dsager.atom'; | |
$feed_content = file_get_contents($url); | |
$feed = new SimpleXMLElement($feed_content); | |
$links = array(); | |
foreach ($feed->entry as $entry) { | |
$time = strtotime($entry->updated); | |
$links[] = array( | |
'id' => (string) $entry->id, | |
'title' => (string) $entry->title, | |
'url' => (string) $entry->link['href'], | |
'time' => $time, | |
'date' => date('F jS, Y', $time) | |
); | |
} | |
usort($links, function ($a, $b) { return $b['time'] > $a['time']; }); | |
echo json_encode($links); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment