Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing public Instagram content via Instagram API without expiring accesstoken

i want to show public contents from instagram related to a specific hashtag (everything works fine with that) but i can't to renew the access_token everytime it expires.

("do not assume your access_token is valid forever." - https://www.instagram.com/developer/authentication/)

To renew it manually is not an option i have to make sure there is a valid access_token at ANY time without re-authenticating.

Any ideas or questions? :)

like image 874
nipeco Avatar asked Dec 06 '16 08:12

nipeco


People also ask

How do you get long live access tokens on Instagram?

Get a Long-Lived TokenYour request must be made server-side and include: A valid (unexpired) short-lived Instagram User Access Token. Your Instagram App Secret (App Dashboard > Products > Instagram > Basic Display > Instagram App Secret)

How do I authenticate and get data using Instagram API?

First of all you need to register as a developer at http://instagram.com/developer/. Click on the Register Your Application button. Now enter your application name, description, website, OAuth redirect URL and captha code and click the Register button.


1 Answers

I have one idea, but without API (and access_token). You can make requests to the web-version of Instagram with ?__a=1 parameter. I do not know how long it will work but now there is workflow:

  1. You want to show public content with hashtag space, for example.
  2. Add it to url and add GET-parameter ?__a=1: https://www.instagram.com/explore/tags/space/?__a=1
  3. Make the GET-request. It returns json with nodes in top_posts (8) and media (18). Each node has owner, caption, number of comments and likes. But the most important part is in thumbnail_src and display_src.
  4. There is page_info in media object which helps to paginate results. You need end_cursor (for example, J0HWE9rjAAAAF0HWE9qvgAAAFiYA)
  5. Add the value from end_cursor to the url: https://www.instagram.com/explore/tags/space/?__a=1&max_id=J0HWE9rjAAAAF0HWE9qvgAAAFiYA
  6. Repeat 3-6 to get newest posts with specific hashtag.
like image 104
rNix Avatar answered Sep 27 '22 16:09

rNix