wis*_*nIV 5 salesforce angularjs angularfire
我创建了一个直接从客户端访问Salesforce REST API的AngularJS服务.但是,由于相同的原产地限制,我无法使其正常工作.即使访问非经过身份验证的REST服务并尝试$ http,$ http.json和Ajax.我也尝试了很多Json,Jsonp等的组合.
鉴于我有这么多问题,我认为我的一般方法是不正确的.也许我需要为此设置代理服务器?我的后端是Firebase,所以我目前没有自己的服务器.
我不相信Salesforce API支持COR,我无法改变它.
这是我尝试使用$ http和Ajax的一个例子.
return $http.jsonp('https://na1.salesforce.com/services/data/',{
headers: {
'Content-type': 'application/json', 'Accept': 'application/json'
}}).
success(function (data, status, headers, config) {
callback(data);
console.debug(data.json);
}).
error(function (data, status, headers, config) {
console.debug("getVersions: failed to retrieve data: "+eval(data));
});
$.ajax({
url: 'https://na15.salesforce.com/services/data',
type: "GET",
dataType: "jsonp",
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
xhrObj.setRequestHeader("X-Requested-With", "XMLHttpRequest");
},
success: function (data) {
console.debug(data);
callback(data);
},
error: function(data) {
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1410 次 |
| 最近记录: |