12

I'm working on a system whose end-users are small and medium business owners. The goal of this feature is to get pictures (in real-time) that others post to Instagram that are tagged with their business location. Note that this is different from pictures that are @-tagged with the business account (ie we want this feed, not this feed).

I was planning on using the real-time subscriptions system documented here since it explains we can subscribe to a location ID and receive notifications about new media at that location. We rolled it out and immediately started failing because there is an unpublished limit of 30 subscriptions (I guess we should have done more googling before starting to build it).

This is basically the same problem outlined here but that conversation is really stale and I'm not sure the end goal is exactly the same since the proposed solutions won't help me.

There are way too many customer accounts to register more applications to get enough subscriptions (we would have to register thousands of apps). We were hoping that we could use an Instagram user's access token obtained through an Oauth2 workflow to create more subscriptions, but my experiments with that haven't panned out either. I know other people have used large geographic area subscriptions instead of location subscriptions, but this won't scale large enough for us either.

I'm frustrated and confused by this problem because:

  1. It seems that other applications are getting these pictures in real-time at a scale that wouldn't fit the limit of 30 subscriptions.
  2. I can't imagine many use cases were 30 subscriptions per application would be a useful feature.

Does anyone have a workaround? Is there a way to use the Instagram User credentials instead of Application credentials? Will I have to resort to polling the location feed regularly and ditch my real-time aspirations?

Community
  • 1
  • 1
Tony Bathgate
  • 392
  • 2
  • 13

2 Answers2

0

Answers to your questions:

There is web-API for some workaround: cronjobs update all your links and write parsed data to your Database. Pluses: no needs API applications. Minuses: sometimes web-API changes (requests and/or responses).

You also can register application for every client in automatic, add them to DB, subscribe to Real-time updates. And then get updates.

There are not ways to use access-token instead of CLIENT-ID and CLIENT-SECRET.

Just remember, that "Real-time" photo updates is not really real-time (balancing system etc.) (from documentation: You should build your system to accept multiple update objects per payload) so 1 minutes updates is enough.

UPD

Maybe help, maybe you already know this gray way to speed up.

You can use direct link to get media by location with web-API. It is simplest. All you need is csrftoken from cookies to generate XHR request. Csrftoken may be from unauthorized user. The request in details you can see in Network tab of Google Chrome.

Simple example: POST query to https://instagram.com/query/ with parameters q and ref (in the example their values are urldecoded to explain):

q=ig_location(237630908){media.after(20000000000000000000000,2){nodes{id,display_src,thumbnail_src}}}&ref=locations::show

Content-type should be application/x-www-form-urlencoded; charset=UTF-8.

Web-headers for XHR request:

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36
Accept: */*
Accept-Language: en-US;q=0.6,en;q=0.4
Referer: https://instagram.com/explore/locations/237630908/
Origin: https://instagram.com
X-Instagram-AJAX: 1
X-Requested-With: XMLHttpRequest
X-CSRFToken: e4e1e1eddd67b2b50b6d8ae7b49e01c0
Cookie: csrftoken=e4e1e1eddd67b2b50b6d8ae7b49e01c0
Content-type: application/x-www-form-urlencoded; charset=UTF-8

(csrftoken in headers example is randomize, don't use it)

Don't use it too often, Instagram sometime disables some web-function by IP, try changes csrftoken.

And an answer is:

{
    status: "ok",
    media: {
        nodes: [
        {
            thumbnail_src: "https://scontent-frt3-1.cdninstagram.com/hphotos-xaf1/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/12142408_1499221190404489_557984803_n.jpg",
            id: "1104470761628620590",
            display_src: "https://scontent-frt3-1.cdninstagram.com/hphotos-xaf1/t51.2885-15/e35/12142408_1499221190404489_557984803_n.jpg"
        },
        {
            thumbnail_src: "https://scontent-frt3-1.cdninstagram.com/hphotos-xaf1/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/12139611_1663826773904632_2063764196_n.jpg",
            id: "1102282973026047789",
            display_src: "https://scontent-frt3-1.cdninstagram.com/hphotos-xaf1/t51.2885-15/e35/12139611_1663826773904632_2063764196_n.jpg"
        }
        ]
    }
}
CnapoB
  • 665
  • 1
  • 9
  • 16
  • Thanks for the answers CnapoB. We have already gone the route of cron jobs but this is unfortunate since it is nowhere near realtime. We've thought about registering a client application for each user, but we'd have to use tens of thousands of apps. I can't imagine Instagram would let us do that. And even if they did it looks like I'd have to get around a captcha to do it automatically. Thanks again. – Tony Bathgate Oct 26 '15 at 15:37
  • You're welcome. Please, see UPD of the answer, it may be help. – CnapoB Oct 26 '15 at 20:10
  • @TonyBathgate I forgot the mention. Sorry. Please, see UPD of the answer, it may be help. – CnapoB Oct 29 '15 at 08:21
  • Yes, thank you for the explanation. I have some experience doing this type of thing before but I'm pretty sure it violates their terms of service. I was hoping to keep things above board on this work. – Tony Bathgate Nov 16 '15 at 14:36
0

I think your problem can be solved with Data365.co Instagram API I work with. This API can fetch posts from geotagged pages and do it quickly enough, within 1-5 minutes. You only should create a task to update the latest publications by location and check if there are any posts there, for example, every 5-10 minutes.

Create a task with auto-update every 300 seconds (POST request) using your location ID 237630908:

https://api.data365.co/v1.1/instagram/location/237630908/update?load_posts=1&max_posts=10&auto_update_interval=300&access_token=TOKEN

You can get answers via a callback or poll the endpoint yourself through the following GET request: https://api.data365.co/v1.1/instagram/location/237630908/posts?access_token=TOKEN

You can also see an API response format in APIs documentation.