Last active
December 15, 2015 10:49
-
-
Save PHLAK/5249009 to your computer and use it in GitHub Desktop.
PHP-CLI script to output a list of repositories (one per line) belonging to the user(s) specified.
This file contains hidden or 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
#!/usr/bin/php -q | |
<?php | |
// Disable errors | |
error_reporting(0); | |
foreach ($argv as $user) { | |
if ($user !== $argv[0]) { | |
// Fetch user repositories from GitHub | |
$apiResults = file_get_contents('https://api.github.com/users/' . $user . '/repos'); | |
if ($apiResults) { | |
// Decode the json object | |
$dataObject = json_decode($apiResults); | |
// Echo all repo URLs | |
foreach ($dataObject as $repo) { | |
echo $user . ";" . $repo->name . ";" . $repo->git_url . PHP_EOL; | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment