We have an Web API (ASP.net & C#) project that collects recent posts (by our organisation) from all four different social networking sites (facebook, twitter, youtube and instagram) and pass them on as json feed to websites and mobile apps.
Luckily, both Facebook and Twitter provides Oauth “client_credentials” flows which allows me to get token when I make a POST request to “token endpoint” with client id, client secret and grant type as “client_credential” as shown below:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
But I am not sure how to tackle Instagram API because it doesn’t give a “client_credentials” flow. Since the token retrieval needs to happen at the backend within a function without an explicit authentication in a web browser.
Has anyone solved this problem?
2
Answers
My way in my old projects. I’m just checking access token still usable. If not open an iframe or popup for get new one. So your mainframe not need to refresh.
retrieving Instagram access_token via api in c# a
If you just want to read Instagram posts.
I know this is a bit late, but i am working on a similar application and i read a post here (stackoverflow) on how to get the Instagram posts. I couldn’t note down the link to the original post, so i am just rewriting the post here. If i find the original post i will add the link here. If anyone finds it, please add it in comments.
Instagram posts can be obtained with the help of your username and with this url:
https://www.instagram.com/YOUR_USER_NAME/media
ex: https://www.instagram.com/NBA/media.
This returns a list of posts, not sure how long. But it returned 20 posts of mine. It also has ‘”more_available”: true,’ so it should be possible to get more.
C# code to get this:
Let me know if this helps.
How to do it with CURL:
http://blog.eezgu.com/2017/03/how-to-get-latest-images-from-instagram.html