Eugene
Eugene

Reputation: 43

Get comments by instagram api

When I'm trying to get comments to media, it returns me only access token owner users comment, and no other users comments.

Query:

https://api.instagram.com/v1/media/"+mediaId+"/comments?access_token="+token

So final query looks like:

https://api.instagram.com/v1/media/1162251688307718037_1824437940/comments?access_token=token

Answer:

`{"meta":{"code":200},"data":[{"created_time":"1453069290","text":"comment_text_here","from":{"username":"username","profile_picture":"profile_picture","id":"user_id","full_name":"full_name"},"id":"1164752089812694405"}]}'

Get media id:

https://api.instagram.com/v1/users/self/media/recent/?access_token="+token+"&count=30

Getting media id list

JSONObject json = new JSONObject(comments);
    JSONArray data = json.getJSONArray("data");
    if (data.length()>0) {
        for (int i = 0; i < data.length(); i++) {
            JSONObject obj = (JSONObject) data.get(i);
            list.add(obj.getString("id"));
            //System.out.println(obj.getString("id"));
        }
    }

Where my mistake or is it api instagram limits for sandbox app ?

Upvotes: 4

Views: 4672

Answers (1)

krisrak
krisrak

Reputation: 12952

Yes in sandbox mode, it will return media only from sandbox authorized users, if u add a user that has commented to your sandbox, then that comment will show up in API response.

https://www.instagram.com/developer/sandbox/

To help you develop and test your app, the users and media available in Sandbox mode are real Instagram data (i.e. what is normally visible in the Instagram app), but with the following conditions:

  • Apps in sandbox are restricted to 10 users
  • Data is restricted to the 10 users and the 20 most recent media from each of those users
  • Reduced API rate limits

Upvotes: 1

Related Questions