Full documentation see: JavaScript - JSON and REST
Used JavaScript library
- jQuery (v.1.10.2)
Get example with OAuth
var client = new HttpClient();
client.httpGet("http://example.org/api/message/", "OAuth " + access_token,
function (data, textStatus, jqXHR) {
console.log("receive: " + textStatus + " " + jqXHR.status + " " + jqXHR.statusText);
$.each( data.objects, function( i, item ) {
// e.g. access attribute name: console.log(item.name)
});
},
function (jqXHR, textStatus) {
console.log("receive: " + textStatus + " " + jqXHR.status + " " + jqXHR.statusText);
$("#getResult").text(completeMessage);
}
);
Post example with OAuth
var client = new HttpClient();
client.httpPost("http://example.org/api/message/", "OAuth " + access_token, data,
function (jqXHR, textStatus) {
console.log("receive: created");
console.log(textStatus + " " + jqXHR.status + " " + jqXHR.statusText);
},
function (jqXHR, textStatus) {
console.log("receive: " + textStatus + " " + jqXHR.status + " " + jqXHR.statusText);
console.log(jqXHR.responseText);
}
);