Instagram API doesn’t find any liked posts for sandbox users
Solution 1
When your app behaves in sandbox mode, it’s restricted compared to normal behaviour. In particular (quoting from the API docs for the sandbox):
The API behaves as if the only users on Instagram were your sandbox users, and the only media ever posted were the last 20 for each of these users.
So the API can’t see posts that the user has liked if those posts were made by non-sandbox users.
Here's a scenario:
Assumptions:
- Say there are 100 instagram users all over the world(I know its more, just for example's sake!).
- An app named APP1 is live and not in sandbox mode.
- An app named APP2 is in sandbox mode[meaning not live yet!].
- There are 5 verified and registered sandbox users for APP2.
Now, as Instagram document has said: Here will be the black box flow.
Situation 1:: APP1 tries to accept user likes for sandbox/non-sandbox users - Result: it gets their data. Reason: For live apps, number of users visible to the app is the the number of users available on instagram.
Situation 2:: APP2 tries to accept user likes: For sandbox user - It will get only those data(likes here) for which the users are registered as sandbox users for this app. Any other likes for non-sandbox users will be not visible here. {As if 5 users existed, if any users like any content of those 5 users, it will be visible.} For non-sandbox users - Users are not visible!
I missed the last part of visibility, which took me some research and co-relation to find out. I guess there might me other developers who might have not understood the sandbox user's visibility part of the document.
Solution 2
If anyone has this problem since after 1st of June, there's a way to bypass that sandbox problem much easier with instagram.pixelunion.net
Later I found a better working one
services.chrisriversdesign.com/instagram-token/
Solution 3
Simple solution, Like one of your own instagram pics. That way your "recent likes" will increase likes of another sandbox user (you), and will not be empty.
Related videos on Youtube
Comments
-
coderz about 4 years
I’m using the Instagram API in sandbox mode. I’m trying to access a User’s liked posts from the Instagram API using their authenticated access token. This user is one of the accepted sandbox users for my app, and has liked some posts.
If I call other endpoints with the same token, I get some data, but accessing
/users/self/media/liked
returns empty data.I’m using this URL:
https://api.instagram.com/v1/users/self/media/liked?access_token={verified access token}
and this is the result I’m receiving:
{"pagination": {}, "meta": {"code": 200}, "data": []}
Because it has a 200 return code, the access token is valid. So why don’t I see any liked posts?
-
coderz over 8 yearsStuck at it for hours now! Have no clue what I'm doing wrong.
-
coderz over 7 years@alexwlchan, many thanks for improving the language of the question asked given the importance of the question. I did made some edits which I guess you overlooked. Kudos to you for helping out!
-
-
Dan Healy over 8 yearsThank you! I was stuck on this for a day. My only question now is, how will Instagram do a proper permissions review if the data returned is only from the sandbox? For example, if I am a solo dev and I am the only person in my app's sandbox and you request my following list, you will see nothing!
-
coderz over 8 years@DanHealy, if you are solo dev, then you can only call those endpoints which fetches your data only!
-
coderz over 8 yearsAlso, @DanHealy, see it in this way, the Instagram sandbox permissions review does it the following manner - only those user who are verified and listed in your app will be visible to it. [Note: You can access only those data of a sandbox user which were posted after that user was verified as a sandbox user for you app - simply putting, if I'm the instagram api, for your sandbox app, I'll only fetch those data which were registered after your registered app time, for only those users who are verified sandbox users of your app! Rest are ignored!] Hope it helps! :)
-
Dan Healy over 8 yearsWhat I mean is, if the functionality of my app relies on using follows / following data, how can they "review" it if there's no data to review?
-
coderz over 8 yearsI'm not sure, most probably they won't run on sandbox mode for review. As stated, they will check those three checkpoints for each of the endpoints you call. Most probably, they are not bothered about it. I'm not sure about that. But technically, they will check your endpoints call!
-
Kalpesh about 8 yearsThanks, Its really helped me. You are looking deep knowledgeable person for Instagram Api. Can you help me to find media-id ?
-
coderz about 8 years@Kalpesh, i'm just a regular user like you who faced the above problem while building it. As i didn't find any good answers here, I thought of sharing my experience so that it might help other too! Thanks! :)
-
AlanP about 8 yearsI'm getting a similar response with api.instagram.com/v1/users/<user-id>/media/recent/… for accessing images. My user in authorized to use the sandbox yet I'm not getting any data back.What am I doing wrong?
-
coderz about 8 years@AlanP, can you be more elaborate? I don't know of your problem.
-
coderz about 8 years@Kalpesh, can you elaborate?
-
AlanP about 8 yearsI have a Instagram account containing images. I have added to the sandbox of the app. After authorizing the app I attempt to access the images using api.instagram.com/v1/users/userid/media/recent/?access_token... and the response is '[body] => {"pagination": {}, "meta": {"code": 200}, "data": []}'. Perhaps Instagram is having an issue so I reported this to them.
-
coderz about 8 years@AlanP, check these two things: 1. The timing of your sandbox mode going live 2. Image posting time-period. So, I believe you don't have any images[aka data] that is posted after the app is submitted for sandbox! If this is the case, post some images now {ie, after the sandbox app live time} and check again. If everything is okay[which I think it is!], you should get data coming in! :)
-
AlanP about 8 years@coderz, that could be true. It has been three days since I added the images but they still do not show up today. And my Client Status says 'Sandbox Mode' so I don't know anything else to do.
-
coderz about 8 years@AlanP, I guess you added them[the images] after your app went live[in sandbox mode]?
-
AlanP almost 8 yearsI logged out and logged in again. Now it is working. Thank you for your assistance.
-
user3562812 almost 8 yearsI used access token from Pixelunion.net, but it doesn't work for this particular problem.
-
kaya almost 8 yearstry the one i added under EDIT, this one was better working with more functionality
-
Phil almost 8 yearsI cant believe Instagram have locked down the API so much you can't even retreive data that is already public. Surely this kind of workaround defeats the whole purpose of using an access token. However, the 2nd site does work for me (even though I can't sign requests without knowing the secret).
-
Tim Hanssen over 7 yearsI search hours for finding out this. Thxs! :D
-
coderz over 7 yearsSpecial thanks to @alexwlchan for editing and simplifying the answer
-
brasofilo about 7 yearsYes, PixelUnion is quite limited, ChrisRivers has restrictions but not as much, eg,
user.data.counts
is not coming up -
Rusty Rob almost 7 yearsalso gives you a good excuse to like your own pics, even if you're not doing any app development ;)
-
user3162130 over 6 yearsIt good for access basic information but if want try get public_content (ex.. get LIKED Media) not work, Please help me!!!!
-
Phillip YS about 6 yearsI have no idea what I should put in Purchase Code section?