pavelk2 / social-feed

JavaScript plugin that shows a user feed from the most popular social networks
http://pavelk2.github.io/social-feed-example/
MIT License
962 stars 304 forks source link

Instagram Issue. Uncaught TypeError: Cannot read property 'id' of undefined #177

Open maximiliankiepe opened 8 years ago

maximiliankiepe commented 8 years ago

the error message:

jquery.socialfeed.js:515 Uncaught TypeError: Cannot read property 'id' of undefined

and refers to this line of code in the jquery.socialfeed.js:

var url = Feed.instagram.api + 'users/' + user.id + '/media/recent/?' + authTokenParams + '&' + 'count=' + options.instagram.limit + '&callback=?';

Client ID and Access token are fine. Is there a solution to this ?

MelchnerRoman commented 8 years ago

i think this has to do with the new Instagram Platform Changes http://developers.instagram.com/post/133424514006/instagram-platform-update https://www.instagram.com/developer/platform_update/

MelchnerRoman commented 8 years ago

I found the fix:

1.) register an application at https://www.instagram.com/developer/

2.) get your user id and use it in "accounts with &"

instagram: { // https://api.instagram.com/v1/users/self/?access_token=XXX accounts: ['&youruserid'], limit: 20, client_id: '[ Client ID ]', access_token: '[ Acces Token ]' // https://api.instagram.com/oauth/authorize/?client_id=[ Client ID ]&redirect_uri=[ Redirect URL ]&response_type=token },

hope i could help!

MelchnerRoman commented 8 years ago

Man now im having issues with this: {"code": 429, "error_type": "OAuthRateLimitException", "error_message": "You have exceeded the maximum number of requests per hour. You have performed a total of 620 requests in the last hour. Our general maximum limit is set at 500 requests per hour."}

maximiliankiepe commented 8 years ago

I could not solve it and in the end I just used instafeed.js additionially.

thejeffsmith commented 8 years ago

MelchnerRoman had the fix: *You might need too change the OAuth Setting Instagram Developer --> Manage Clients --> Settings --> Uncheck - Disable implicit OAuth

Step One - Access Token: Place your client id and redirect URL in the string below https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URL&response_type=token

Step Two - ID: Place the access token returned from step one in the string below https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN-FROM-STEPONE or look at the first part of the access token before the first .

Step Three: Grab the ID-Number from ID: ' ' at the end of the string

instagram: { accounts: ['&ID-Number'], limit: 20, client_id: 'Client-ID', access_token: 'Access-Token', }

To fix: {"code": 429, "error_type": "OAuthRateLimitException", "error_message": "You have exceeded the maximum number of requests per hour. You have performed a total of 620 requests in the last hour. Our general maximum limit is set at 500 requests per hour."}

At the end of the socialfeed.js update the original chainable initialization // Original Initialization //Feed.init(); //if (options.update_period) { // setInterval(function() { // return Feed.init(); // }, options.update_period); //}

// Updated Initialization Feed.init(); if (options.update_period) { var startTime = new Date().getTime(); var interval = setInterval(function(){ if(new Date().getTime() - startTime > 1200000){ clearInterval(interval); return; } Feed.init(); return; }, options.update_period); }

MelchnerRoman commented 8 years ago

Thank you for your help - im gonna give it a try today! :)

andreabrunato commented 8 years ago

Maybe it only need the scope "public_content" on the token generation? I've solved using this: https://github.com/pavelk2/social-feed/issues/184