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
963 stars 304 forks source link

Instagram example broken? #316

Open stockmind opened 6 years ago

stockmind commented 6 years ago

The example shown in README didn't work. The only way i got it work for my account was doing the following:

instagram:{
            accounts: ['&CLIENTID'],  //Array: Specify a list of accounts from which to pull posts
            limit: 1,                                   //Integer: max number of posts to load
            client_id: 'CLIENTID',       //String: Instagram client id (option if using access token)
            access_token: 'ACCESSTOKEN' //String: Instagram access token
        },

The following didn't work:

instagram:{
            accounts: ['@ACCOUNTNAME'],  //Array: Specify a list of accounts from which to pull posts
            limit: 1,                                   //Integer: max number of posts to load
            client_id: 'CLIENTID',       //String: Instagram client id (option if using access token)
            access_token: 'ACCESSTOKEN' //String: Instagram access token
        },

I was doing something wrong?

HartLarsson commented 6 years ago

the demo don't have the Tokens and parameters wrote on because in the past many people used the Pavel keys and was not a good idea. Because the keys are public, probably Pavel removed them. The best way to deal with private tokens and keys will be create an extra php file with embedded the tokens and secret keys that connect to socials and give back a json for the js script.

In this way no one can steal secret tokens (very dangerous to make them public) and the demo can work properly :)

stockmind commented 6 years ago

... That's totally not the problem i had, as i shown in my examples above i simply had to specify my "CLIENTID" as account name instead of the real ACCOUNTNAME in the accounts section to let the script harvest my feed. My question was if i did something wrong or if is supposed to work like this, that's because it took lot of try and guess looking into the code to come to working a solution 😅

Looking at the code i was able to find the url and try it by hand, and if i try to reach my account searching by account name i just get this : This client has not been approved to access this resource.

So the problem was probably this.

I've made a pull request to add the "attachment_url" feature for templates as it's really useful for customized templates, and i was thinking on make a pull request to improve the docs example, but first i wanted to understand this thing.

mutiullah7 commented 6 years ago

Can you help me to show my instagram feeds too, im unable to show my feeds with my client id and access token

stockmind commented 6 years ago

Try this:

instagram:{
            accounts: ['&CLIENTID'],  //Array: Specify a list of accounts from which to pull posts
            limit: 1,                                   //Integer: max number of posts to load
            client_id: 'CLIENTID',       //String: Instagram client id (option if using access token)
            access_token: 'ACCESSTOKEN' //String: Instagram access token
        },

Use & character followed by your client id as account name, then put your data in client_id and access_token. This should work.

mutiullah7 commented 6 years ago

did as you asked exactly, getting error Failed to load resource: the server responded with a status of 404 ()

mutiullah7 commented 6 years ago

Instagram API changes – April 4, 2018

Due to some sudden changes that Instagram has made to their API on April 4th, 2018

User Feeds It is still possible to display your own Instagram account, however, Instagram has removed the ability to display user feeds from other Instagram accounts which are not your own. You can only display the user feed of the account which is associated with your Access Token, but it is no longer possible to display someone else’s feed using your own Access Token.

Public Comments It is possible to display comments on your own user feeds, but it is no longer possible to display comments on posts in hashtag or location feeds.

Avatars It is no longer possible to display the avatars of users in hashtag or location feeds.

mutiullah7 commented 6 years ago

@HartLarsson Any updates? https://www.instagram.com/developer/changelog/

HartLarsson commented 6 years ago

due to new API changes you need a CLIENTID you can get your CLIENTID use this tool: https://codeofaninja.com/tools/find-instagram-user-id

use it like &YOURCODE as a instagram account and will work

mutiullah7 commented 6 years ago

It worked, thanks

mutiullah7 commented 6 years ago

getting feed from hashtag but its not showing the display pictures, any ideas

kilianso commented 6 years ago

Another working option to get JSON from any Instagram-account or hashtag without even using an access-token is by adding ?_a=1 to the URL.

Userfeed: https://www.instagram.com/YOURUSER/?__a=1

Hashtag: https://www.instagram.com/explore/tags/YOURHASHTAG/?__a=1

And to request the next portion of entries you can use add the end_cursor value from the previous fetch like this:

https://www.instagram.com/explore/tags/YOURHASHTAG/?__a=1&max_id=END_CURSOR_ID

This is working since years, but who knows... with all the API changes and data-leak discussions, they may shut that down soon.