【问题标题】:instagram web api net::ERR_BLOCKED_BY_RESPONSEinstagram web api net::ERR_BLOCKED_BY_RESPONSE
【发布时间】:2021-04-21 19:51:38
【问题描述】:

我已经通过标签创建了一个简单的照片库

使用instagram-web-apielectron

主要流程:

const Instagram = require('instagram-web-api')
const client = new Instagram({})
ipc.on('get-photos', (event, hashtagFromClient) => {
createPhotoArray()

async function createPhotoArray() {
    let photoArray = []

    let p = await client.getPhotosByHashtag({ hashtag: hashtagFromClient })

    for (let i = 0; i < p.hashtag.edge_hashtag_to_media.edges.length; i++) {
        photoArray.push([p.hashtag.edge_hashtag_to_media.edges[i].node.thumbnail_src, p.hashtag.edge_hashtag_to_media.edges[i].node.edge_liked_by.count])
    }

    event.sender.send('gallery-created', photoArray)
}
})

渲染过程:

ipc.send('get-photos', game.userData.hashtag)

ipc.on('gallery-created', function (event, photoArr) {
    photoArray = photoArr
    maxNumIMG = photoArray.length
    for (let i = 0; i < photoArray.length; i++) {
        myTimeout = setTimeout(function () { createNewPhoto(photoArray[i][0]) }, gapTime * i)
    }
})

但我看到浮动错误:

net::ERR_BLOCKED_BY_RESPONSE

我该如何解决?

【问题讨论】:

标签: api npm electron instagram response


【解决方案1】:

Instagram 最近更改了其 CORS 政策。您必须设置请求标头 Host 才能绕过该策略。

【讨论】:

  • 你能举个例子吗?
  • 非常感谢。我非常感激。你能举个例子吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-01
  • 2018-05-08
  • 2015-09-04
  • 1970-01-01
  • 1970-01-01
  • 2021-11-30
相关资源
最近更新 更多