Created
August 28, 2011 13:56
-
-
Save cadwallion/1176690 to your computer and use it in GitHub Desktop.
Quick V3 API hack, assumes you handle the OAuth
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
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