简体   繁体   English

Instagram 公共 API 的新 CORS 政策?

[英]New CORS policy for Instagram public API?

I am using these endpoints with JavaScript Ajax to get Instagram user information and posts:我将这些端点与 JavaScript Ajax 一起使用来获取 Instagram 用户信息和帖子:

https://www.instagram.com/[username]/?__a=1 https://www.instagram.com/[用户名]/?__a=1

https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&variables={id:[user_id],first:50,after:''} https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&variables={id:[user_id],first:50,after:''}

There was not a CORS policy error before but now i'm getting that error (not every time when i refresh the page, but almost 95% times):之前没有 CORS 策略错误,但现在我收到了该错误(不是每次刷新页面时,但几乎是 95% 次):

Access to XMLHttpRequest at 'https://www.instagram.com/hannahstocking/?__a=1' from origin 'https://sitename.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.从来源“https://sitename.com”访问“https://www.instagram.com/hannahstocking/?__a=1”的 XMLHttpRequest 已被 CORS 策略阻止:无“Access-Control-Allow-Origin” header 出现在请求的资源上。

Has Instagram started to block these endpoints or added a new rate limit? Instagram 是否已开始阻止这些端点或添加新的速率限制? How can I fix it?我该如何解决?

Instagram has introduced a strict-origin-when-cross-origin policy and is only allowing the following cross origin sites: Instagram 引入了严格的跨域策略,并且只允许以下跨域站点:

  • https://www.instagram.com https://www.instagram.com
  • https://*.fbcdn.net https://*.fbcdn.net
  • https://*.instagram.com https://*.instagram.com
  • https://*.cdninstagram.com https://*.cdninstagram.com
  • https://*.facebook.com https://*.facebook.com
  • https://*.fbsbx.com https://*.fbsbx.com

This leads me to believe that they are restricting websites to display the API data.这让我相信他们正在限制网站显示 API 数据。 The data itself is still accessible, just not directly over a website.数据本身仍然可以访问,只是不能直接通过网站访问。 You would need to use a proxy or a server to resolve it您需要使用代理或服务器来解决它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM