Skip to content

Instantly share code, notes, and snippets.

@lumenwrites
Last active August 29, 2015 14:10
Show Gist options
  • Save lumenwrites/4d31e3106d19f2f2996e to your computer and use it in GitHub Desktop.
Save lumenwrites/4d31e3106d19f2f2996e to your computer and use it in GitHub Desktop.
function challengeUser (){
var xhr = new XMLHttpRequest();
var id = 58542; //Fuego bot user id
var url = "http://online-go.com/api/v1/players/"+id+"/challenge/";
xhr.open("POST", url, true );
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
console.log('Status: '+xhr.status+
'\nHeaders: '+JSON.stringify(xhr.getAllResponseHeaders())+
'\nBody: '+xhr.responseText);
}
};
var gameSettings = {
"game": {
"name": "a test game",
"rules": "japanese",
"ranked": false,
"handicap": 0,
"time_control_parameters": {
"time_control": "fischer",
"initial_time": 259200,
"max_time": 604800,
"time_increment": 86400
},
"pause_on_weekends": true,
"width": 9,
"height": 9,
"disable_analysis": true
},
"challenger_color": "automatic",
"min_ranking": 0,
"max_ranking": 0
};
gameSettings = JSON.stringify(gameSettings);
xhr.send(gameSettings);
}
qml: Status: 0
Headers: "server: nginx/1.6.1\r\ndate: Sat, 22 Nov 2014 20:58:14 GMT\r\ncontent-type: text/html\r\ntransfer-encoding: chunked\r\nconnection: close\r\nvary: Accept-Language, Cookie\r\ncontent-language: en"
Body:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment