我在使用API方面很新颖,而且我对Instagram的新api有问题。Instagram API。 XMLHttpRequest无法加载URL。预检的响应具有无效的HTTP状态代码405
对于不喜欢的功能,文档状态使用delete方法,但我不断收到一个错误:XMLHttpRequest cannot load URL. Response for preflight has invalid HTTP status code 405.
有趣的是,当我尝试用卷曲完全一样的东西,它的工作原理。
例如,这是一个工作方法:curl -X DELETE https://api.instagram.com/v1/media/{media-id}/likes?access_token=ACCESS_TOKEN
但是,如果我尝试使用JavaScript
if(user_has_liked){
$.ajax({
crossDomain: true,
url: "https://api.instagram.com/v1/media/"+ photoId +"/likes?access_token=" + ACCESS_TOKEN,
method: 'DELETE',
success: function(data){
response = data.data;
document.getElementById(photoId).className = "fa fa-heart-o";
document.getElementById(photoId).onClick = function(){
subscribe(photoId, false);
}
}
});
}
使用它我得到的是一个405错误。
我试图使CORS,但它似乎工作,要么
我会很感激,如果有人可以给我一只手搭在此。
非常感谢!
“我试着让CORS,但它似乎工作,要么” - 如何?你是否为Instagram工作,并有能力将代码部署到他们的API服务器? – Quentin