pconnor88 / instagram-profile-widget

A jQuery Instagram profile widget for your website
3 stars 1 forks source link

Uncaught TypeError: Cannot read property 'length' of undefined #2

Open Frostbourn opened 8 years ago

Frostbourn commented 8 years ago

Hi

Is this project still alive? Can I ask you for help?

I am trying to use your widget on my website but I get this error message:

Uncaught TypeError: Cannot read property 'length' of undefined

if(data.data.length > 0) 
            {
                o.userID = data.data[0].id;
                $(o.element).find(".insta-profile-username").text(data.data[0].username);
                $(o.element).find(".insta-profile-avatar").append("<a target =\"_blank\" href=\"https://instagram.com/" + data.data[0].username + "\"><img src=\"" + data.data[0].profile_picture + "\"></a>");
                $(o.element).find(".insta-profile-btn").attr("href", "https://instagram.com/" + data.data[0].username);
                o.sendRequest("users/" + o.userID + "/", {}, o.callbackUserStats);

            } 
            else 
            {
                alert("No user was found");
            }
pconnor88 commented 8 years ago

Can you paste a link to your code, so I can see how you are calling the widget?

Frostbourn commented 8 years ago

I know what the issue is:

Important Apps created on or after Nov 17, 2015 can take advantage of Sandbox mode right away. Apps created before this date will only be able to use Sandbox mode after June 1, 2016, but can still start submitting for review. On June 1, 2016 any app that has not been reviewed and approved will be set to sandbox mode.

  $('.instagram_box #loader').fadeOut(300);
                            $(".instagram-widget").ProfileWidget({
                                username: "username",
                                clientID: "clientID"
                            });
pconnor88 commented 8 years ago

Yes, that does seem to be the issue. So I suggest you submit your Instagram app for approval. However, it does seem as though the widget should still work in sandbox mode, just with limited API calls, so I will have a quick run through the code later and see if I can fix it.

I will also add some error handing to stop the length undefined error.

Frostbourn commented 8 years ago

Thank you for your response.

pconnor88 commented 8 years ago

It seems as though Instagram have decided to remove access to their API using just the client ID token. Everything has to now be done through oAuth, which means the user needs to give permission to the app before it can work.

That basically renders this plugin useless/dead, as you don't want to be asking everyone who comes to your website to authenticate. Sorry I can't help any further.