如何从Instagram API获取评论数据

时间:2019-09-18 10:29:24

标签: instagram-api

我尝试使用API​​获得Instagram媒体评论。使用API​​时,我得到的是空数组。我已经尝试过沙盒直播,也将个人资料设为公开,但评论数据仍然为空。

   instagram.get('/media/2128588978223438874_685479/comments').then(data=> {
    console.log(data); })
        .catch(err => {
            console.log(err);

        })



I expected the output was : {
    "data": [
        {
            "created_time": "1280780324",
            "text": "Really amazing photo!",
            "from": {
                "username": "snoopdogg",
                "profile_picture": "http://images.instagram.com/profiles/profile_16_75sq_1305612434.jpg",
                "id": "1574083",
                "full_name": "Snoop Dogg"
            },
            "id": "420"
        },
        ...
    ] } .

但是我得到的实际输出是

{ data: [], meta: { code: 200 } }

1 个答案:

答案 0 :(得分:0)

media-id只是真实ID的占位符。更换它,它将起作用。
Here是获取媒体信息及其ID的请求。

instagram.get('/media/' + media_id + '/comments')
         .then(data => {
            console.log(data); 
         })
         .catch(err => {
            console.log(err);
         })