Summary
The CANDDi API can be accessed from your own application by making cross-domain requests. The sample code below demonstrates how to make this happen
var createCORSRequest = function (method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (
typeof XDomainRequest != "undefined"
) {
xhr = new XDomainRequest();
xhr.open(method, url);
} else { xhr = null; }
return xhr;
};
var strSlug = "[YOUR COMPANY]";
var strAPI_key = "[YOUR_API_KEY]";
var url = 'https://'+strSlug + '.canddi.com/hello';
var method = 'GET';
var xhr = createCORSRequest(method, url);
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("canddi_api", strAPI_key);
xhr.onload = function () { alert("Success"); };
xhr.onerror = function() { alert("Error");};
xhr.send();
Comments