If I was to go about displaying just MY github repositories and their contents on an external website how would i go about doing this? Are there any source code\'s you can
All these examples are just as pseudo without "authentication" and you can improve them yourself as you like;
stdClass Object
(
[language] => JavaScript
[merges_url] => https://api.github.com/repos/qeremy/mii/merges
[contributors_url] => https://api.github.com/repos/qeremy/mii/contributors
[assignees_url] => https://api.github.com/repos/qeremy/mii/assignees{/user}
[url] => https://api.github.com/repos/qeremy/mii
[description] => Multipurpose JavaScript Library
[ssh_url] => git@github.com:qeremy/mii.git
[comments_url] => https://api.github.com/repos/qeremy/mii/comments{/number}
[statuses_url] => https://api.github.com/repos/qeremy/mii/statuses/{sha}
[keys_url] => https://api.github.com/repos/qeremy/mii/keys{/key_id}
...
stdClass Object
(
[_links] => stdClass Object
(
[self] => https://api.github.com/repos/qeremy/mii/contents/README.md
[git] => https://api.github.com/repos/qeremy/mii/git/blobs/49f0c4d5e25ac44921ba4372aebd76d2da5128e2
[html] => https://github.com/qeremy/mii/blob/master/README.md
)
[url] => https://api.github.com/repos/qeremy/mii/contents/README.md
[type] => file
[sha] => 49f0c4d5e25ac44921ba4372aebd76d2da5128e2
[path] => README.md
[size] => 8213
[encoding] => base64
[content] => QWN0dWFsbHksIEkga25vdyB0aGF0IHRoZXJlIGFyZSBidWNoIG9mIEphdmFT
Y3JpcHQgbGlicmFyeSwgZXZlbiBtb3JlIHBvd2VyZnVsbC4gQnV0IHNvbWV0
...
But, I think needs more complicated structure;
user = $user;
}
public function listRepos() {
$this->_request(
sprintf($this->src_userRepos, $this->user));
if ($this->responseCode != 200) {
throw new Exception('Server error!'); // e.g
}
return json_decode($this->responseText);
}
public function getRepoDetails($repo) {
$this->_request(
sprintf($this->src_userRepoDetails, $this->user, $repo));
if ($this->responseCode != 200) {
throw new Exception('Server error!'); // e.g
}
return json_decode($this->responseText);
}
// Could be extended, e.g with CURL..
protected function _request($url) {
$contents =@ file_get_contents($url);
$this->responseCode = (false === $contents) ? 400 : 200;
$this->responseText = $contents;
}
}
// Test
$gr = new GRepo('qeremy');
print_r( $gr->listRepos() );
print_r( $gr->getRepoDetails('mii') );
?>