0

我试图绕过 sop 从 marketo api 获取潜在客户详细信息。是否可以使用 CORS 或 JSONP。似乎不是,但我担心我的代码中可能存在错误。

我正在使用“第三方 Javascript”一书中的 CORS 方法大纲

function createCORSRequest(method, url){
  var xhr = new XMLHttpRequest();
  if ("withCredentials" in xhr){
      console.log('We have credentials');
      xhr.open(method, url, false);
  } else if (typeof XDomainRequest != "undefined"){
      xhr = new XDomainRequest();
      xhr.open(method, url, false);
      console.log('Domain request is undefined');
  } else {
      xhr = null;
      console.log('null null null');    
  }

  return xhr;
};

xhr = new createCORSRequest();
xhr.open("GET", {url}, false);
xhr.send();

目前我收到标准的肥皂错误。

我是否只需要在接收文档的域上创建一个新的 api。实际上是 Marketo rest api 的包装器。

4

1 回答 1

0

我是否只需要在接收文档的域上创建一个新的 api。实际上是 Marketo rest api 的包装器。

这确实是最好的方法。可能有一些方法可以用来规避它,但从安全角度来看,暴露你的访问令牌确实是个坏消息。

于 2015-09-30T17:08:10.020 回答