【发布时间】:2014-06-23 00:43:51
【问题描述】:
我想在 instagram 上调用此链接,我正在使用以下代码,但它不起作用。出现以下错误,请帮助我如何从本地主机和服务器调用此 url。
var likeurl = "https://api.instagram.com/v1/media/" + idslist[1] + "/likes?ACCESS_TOKEN=" + accesstoken;
Nextin_downloadData(likeurl);
$.ajax({
url: likeurl,
type: 'POST',
data: {
},
success: function (result) {
alert("out" + result);
},
error: function () {
alert("error");
}
});
Error : XMLHttpRequest cannot load https://api.instagram.com/v1/media/714346267865083830_540073674/likes? ACCESS_TOKEN=1281148571.506af84.fc2e95e7257fdhgu5thca. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:2356' is therefore not allowed access.
【问题讨论】:
-
在这种情况下使用 POST 可能不是正确的选择,因为跨源 ajax 调用。
$.getJSON()或$.ajax({ type: GET", dataType: "jsonp"})会更好 -
这是一个邮局电话收不到请查收。 [instagram.com/developer/endpoints/relationships/…
-
对不起,我的错误。要启用 CORS,您需要配置服务器设置的 HTTP 标头,例如Apache、IIS 等
-
没事没问题。我正在使用 IIS 来配置 HTTP 标头?
标签: jquery url xmlhttprequest instagram