問題描述
我將這些端點與 JavaScript Ajax 一起使用來獲取 Instagram 用戶信息和帖子:
https://www.instagram.com/[用戶名]/?__a=1
https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&variables={id:[user_id],first:50,after:''}
以前沒有 CORS 策略錯誤,但現在我收到了該錯誤(不是每次刷新頁面時,但幾乎 95% 次):
CORS 政策已阻止從源https://sitename.com"訪問https://www.instagram.com/hannahstocking/?__a=1"處的 XMLHttpRequest:無訪問權限-請求的資源上存在 Control-Allow-Origin 標頭.
Instagram 是否已開始阻止這些端點或添加了新的速率限制?我該如何解決?
Instagram 引入了 strict-origin-when-cross-origin 政策,只允許以下跨源網站:p>
- https://www.instagram.com
- https://*.fbcdn.net
- https://*.instagram.com
- https://*.cdninstagram.com
- https://*.facebook.com
- https://*.fbsbx.com
這讓我相信他們正在限制網站顯示 API 數據.數據本身仍然可以訪問,只是不能直接通過網站訪問.您需要使用代理或服務器來解決它
I am using these endpoints with JavaScript Ajax to get Instagram user information and posts:
https://www.instagram.com/[username]/?__a=1
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):
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.
Has Instagram started to block these endpoints or added a new rate limit? How can I fix it?
Instagram has introduced a strict-origin-when-cross-origin policy and is only allowing the following cross origin sites:
- https://www.instagram.com
- https://*.fbcdn.net
- https://*.instagram.com
- https://*.cdninstagram.com
- https://*.facebook.com
- https://*.fbsbx.com
This leads me to believe that they are restricting websites to display the API data. 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
這篇關于Instagram 公共 API 的新 CORS 政策?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!