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 用C语言输入方程怎么
    • ¥15 网站显示不安全连接问题
    • ¥15 github训练的模型参数无法下载
    • ¥15 51单片机显示器问题
    • ¥20 关于#qt#的问题:Qt代码的移植问题
    • ¥50 求图像处理的matlab方案
    • ¥50 winform中使用edge的Kiosk模式
    • ¥15 关于#python#的问题:功能监听网页
    • ¥15 怎么让wx群机器人发送音乐
    • ¥15 fesafe材料库问题