I've been trying to retrieve the users who have commented on a picture at Instagram. The issue I'm facing is that you require the media ID
of the image to use in the api endpoint. I'm using this code to get the media ID
of the image:
$api = file_get_contents("http://api.instagram.com/oembed?url=https://www.instagram.com/p/BBHOUQyuS3T/?taken-by=kimkardashian");
$apiObj = json_decode($api,true);
$media_id = $apiObj['media_id'];
print_r($media_id);
which gives me a media ID
of 1172969193024859603_18428658
.
When I input this into my api request like this:
$api = file_get_contents("http://api.instagram.com/v1/media/".$media_id."/comments?access_token=".$access_token);
with my particular access_token
, I get a 400 error code. When I go direct to the page url, it says:
Invalid media id.
Has anyone else had this problem before? If so how did you solve it?
Another puzzling part of this is that, after looking around the Stackoverflow for a while, I found a couple ways of translating the shortcode for the picture into the media ID
.
One of them is nodejs
module here which gives me a media ID
for the image of 1172969193024859603
, so like the original but without the bit after the underscore. Both ID's give me the same error.
I've been at this for hours and it's driving me mad! Please help.