我想通过使用终结点的请求来取消关注instagram上的特定用户,为此我使用了提琴手来查找。 但是我收到403错误,什么都没发生。我是这个新手。
代码如下:
var http = new XMLHttpRequest();
var url = 'https://www.instagram.com/web/friendships/8752655712/unfollow/';
var params = 'orem=ipsum&name=binny';
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
我缺少任何技术方面的内容吗?
编辑1:登录到我的instagram帐户时,我正在从Chrome控制台发送它。
答案 0 :(得分:1)
是的,您缺少一些东西。
身份验证
当您像往常一样浏览Instagram时,浏览器将为每个请求添加标题。更重要的是,标头包含cookie和来源。通过执行代码,您列出的标头(或任何其他身份验证数据)不会添加。
其他安全检查
我猜想Instagram检查收到的请求的来源。可能无法以这种方式执行它-即手动执行JS代码。
可能的解决方案-使用Instagram提供的API。有关更多详细信息,请参阅文档:https://www.instagram.com/developer/