weixin_33676492 2020-02-02 16:53 采纳率: 0%
浏览 304

如何使用Instagram API?

I have a problem since few minutes, my code worked perfectly and for a few minutes I have a problem, i have this message error :

main.js:6 Uncaught TypeError: Cannot read property 'user' of undefined

my JS code :

function getInstagram(id) {
    $.ajax({
        url: 'https://www.instagram.com/' + id + '?__a=1',
        type: 'get',
        success: function (response) {
            posts = response.graphql.user.edge_owner_to_timeline_media.edges;
            posts_html = '';
            is_private = response.graphql.user.is_private;

            if (is_private === true) {
                $("#private").css("display", "none");
            } else {
                $("#private").css("display", "block");
            }

            if (Array.isArray(posts) && posts.length) {
                for (var i = 0; i < 4; i++) {
                    url = posts[i].node.display_url;
                    posts_html += '' +
                        '<div class="col-md-3">' +
                        '<img style="max-height:200%; width:100%; cursor: pointer" src="' + url + '" onclick="onClick(this)">' +
                        '</div></div>';
                }
            }
            $(".posts").html(posts_html);
        },
        error: function (xhr) {
            if (xhr.status === 404) {
                $("#private").css("display", "none");
            }
        },
    });
}

I tried to look at the request on Postman and i can see they ask for login but normaly i dont need to looking to get all the pics from a public instagram

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 有没有帮写代码做实验仿真的
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥30 vmware exsi重置后登不上
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?