【问题标题】:instagram ?__a=1 not working in Mobile but when we hit the api in browser and postmen its working fineinstagram ?__a=1 在移动设备中不起作用,但是当我们在浏览器和邮递员中点击 api 时,它工作正常
【发布时间】:2020-12-16 07:10:36
【问题描述】:

它在过去 5 天停止工作,然后才正常工作。

现在,当我们在移动设备中调用此端点时,返回 429 并重定向到 Instagram 登录页面。

【问题讨论】:

  • 您找到解决方案了吗?我也面临同样的问题
  • 您找到解决方案了吗?我也遇到了同样的问题

标签: api mobile instagram instagram-api unauthorized


【解决方案1】:

我遇到了同样的问题,我已通过将请求标头中的 User-Agent 更改为 Mozilla/5.0 来解决它。

这是我在 iOS (Swift) 上所做的:

let url = URL(string: "https://www.instagram.com/spacex/?__a=1")
let request = NSMutableURLRequest(url: url)
request.setValue("Mozilla/5.0", forHTTPHeaderField: "User-Agent")
request.setValue("no-cache", forHTTPHeaderField: "Cache-Control")
request.httpMethod = "GET"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
let session = URLSession.shared

DispatchQueue.global(qos: .background).async {
  let requestData = session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
    if let error = error {
      print("Error @ loadInstagram(): \(String(describing: error))")
      return
    }
    
    if let data = data {
      self.processInstagram(data: data) // function for processing the json data received
    } else {
      print("Error - missing data @ loadInstagram()")
    }
  }
  requestData.resume()
}

【讨论】:

  • 不适合我
猜你喜欢
  • 2017-12-18
  • 2021-11-02
  • 1970-01-01
  • 2019-10-02
  • 2021-08-20
  • 1970-01-01
  • 2015-08-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多