This repository was archived by the owner on Apr 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Submitting a Score
AutomatedTester edited this page Dec 7, 2011
·
2 revisions
Powerball has the ability to have things outside of the web application submit a score for a user. This means that people can create browser extensions that can submit scores and can earn users badges!
##Scoring API
To submit a score you will need to do a post to /score/userID/game and pass in a dictionary with a key for points. You can get userID from the your profile page. Login and then click on your name in the top right of the page. This will take you to your Profile page
An example would be
var path = '/score/4ede81e228680a570c000008/l10n'
, req = http.request({ path: path , port: 3000, method: "POST" }, function(res) {
assert.ok(res.statusCode === 200);
var buf = '';
res.on('data', function(chunk){
buf += chunk
});
res.on('end', function(){
var result = JSON.parse(buf);
assert.ok(result.result === "success");
assert.ok(result.message === "score locked away in the datastore");
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write('{"points":"1"}');
req.end();
});
You will be returned a JSON blob that looks like
{"result":"success", "message":"score locked away in the datastore"} or result will be failure if something went wrong!