Skip to content

Instantly share code, notes, and snippets.

@cadwallion
Created August 28, 2011 13:56
Show Gist options
  • Save cadwallion/1176690 to your computer and use it in GitHub Desktop.
Save cadwallion/1176690 to your computer and use it in GitHub Desktop.
Quick V3 API hack, assumes you handle the OAuth
var https = require('https');
var Github = module.exports = {
setAuthToken: function (token) {
this.access_token = token;
},
send: function (path, callbk) {
if (this.access_token != undefined) {
options = {
host: 'api.github.com',
path: path + "?access_token=" + this.access_token
}
https.get(options, function(res) {
var buffer = '';
res.on('data', function(d) {
buffer += d;
});
res.on('end', function() {
callbk(buffer);
});
});
} else {
return "Please authenticate first."
}
},
getCommitsByRepo: function (repo, callbk) {
this.send('/repos/' + repo + '/commits', callbk);
},
getCommitCommentsByRepo: function (repo, callbk) {
this.send('/repos/' + repo + '/comments', callbk);
},
getCommitCommentsBySha: function(sha, callbk) {
this.send('/repos/' + repo + '/commits/' + sha + '/comments', callbk);
},
getWatchedRepos: function (callbk) {
this.send('/user/watched', callbk);
},
getFollowing: function (callbk) {
this.send('/user/following', callbk);
},
getFollowers: function (callbk) {
this.send('/user/followers', callbk);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment