現在、MarketoのAPIからデータを取得して送信しようとしています。問題は、私のウェブプラットフォームがSalesforce Communityです。私がこのウェブツールを正しく理解していれば、私は純粋なjavascript以外のものを使用することはできません。JavaScriptのみを使用してMarketo APIを呼び出す
私はこのようなCORS要求構築した:http://www.html5rocks.com/en/tutorials/cors/の助けを借りて
function createCORSRequest(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;
}
function makeCorsRequest() {
var url = document.getElementById('url').value;
var xhr = createCORSRequest('GET', url);
if (!xhr) {
alert('CORS not supported');
return;
}
xhr.onload = function() {
var text = xhr.responseText;
alert('Response from CORS request to ' + url + 'is : ' + text);
};
xhr.onerror = function() {
alert('Woops, there was an error making the request.');
};
xhr.send();
}
を、このエラーが戻ってくるので、サーバーは要求を受け入れていないようだ。
「いいえ'Access-Control-Allow-Origin'ヘッダーは、要求されたリソース上に存在します。したがって、 'http://testurl ...'はアクセスできません。
MarketoのAPIがCORSリクエストを受け入れるかどうかは知りませんか?それとも私がこれを解決するのに役立つアイデアを持っているのでしょうか?どうもありがとうございました。