Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Created September 4, 2012 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottgonzalez/3626141 to your computer and use it in GitHub Desktop.
Save scottgonzalez/3626141 to your computer and use it in GitHub Desktop.
GitHub Commit Status API example
var https = require( "https" ),
username = "xxx",
password = "xxx";
function postStatus( settings, fn ) {
var data = JSON.stringify( settings ),
headers = {
"Content-length": data.length
};
headers.Authorization = "Basic " + new Buffer( username + ":" + password ).toString( "base64" );
var req = https.request({
host: "api.github.com",
port: 443,
path: "/repos/scottgonzalez/jquery-ui/statuses/c20cef6ae83b13af93fb8c999c0be8d51a5c50fe",
method: "POST",
headers: headers
}, function( res ) {
var response = "";
res.setEncoding( "utf8" );
res.on( "data", function( chunk ) {
response += chunk;
});
res.on( "end", function() {
fn( JSON.parse( response ) );
});
});
req.write( data );
req.end();
}
postStatus({
state: "pending"
}, function() {
console.log( arguments );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment