I have two access_tokens:
- From Instagram Graph API:
var fs_access_token
, which I get after I log in with Facebook; - From Instagram Basic Display:
var inst_access_token
; SO I have the collection of posts' ids, which I get throughig_hashtag_search
:
var posts_ids; //!= null;
I also have 3 posts on my Instagram business account. And I try to get usernames of all this posts that I have in my collection with one endpoint:
for (var u = 0; u < posts_ids.length; u++) {
fetch("https://graph.instagram.com/" + posts_ids[u] + "?fields=username&access_token=" + inst_access_token).then(function (response) {
response.text().then(function (text) {
alert(text); //using Instagram Basic Display
});
});
}
But then I get the error from this request:
{
"error": {
"message": "Unsupported get request. Object with ID '17884048231750634' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
"type": "IGApiException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "AKiycowo9LbwZbKzxOL-EQ9"
}
}
Interesting fact: if I insert the id of one of posts that I have on my Instagram business account instead of posts_ids[u], then it WILL work! SO, what the hell's going on here? It means that I can get "username data" only from posts that I have on Instagram account, doesn't it? Or what? I also tried to get usernames with other endpoind, where of course I used other access_token, which I get after I log in Facebook(access_token that I used above was access_token, which I get after I log in Instagram; Instagram Graph API - log in Facebook, and Instagram Basic Display - log in Instagram):
for (var u = 0; u < posts_ids.length; u++) {
fetch("https://graph.facebook.com/v8.0/" + posts_ids[u] + "?fields=username&access_token=" + fs_access_token).then(function (response) {
response.text().then(function (text) {
alert(text);
});
});
}
But then I again get the error from request:
{
"error": {
"message": "Unsupported get request. Object with ID '17884048231750634' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "AhN5o9eopccP4NrQsu8QuaN"
}
}
And again interesting fact: if I insert the id of one of posts that I have on my Instagram business account instead of posts_ids[u], then it WILL work! I also tried to do so:
for (var u = 0; u < posts_ids.length; u++) {
fetch("https://graph.facebook.com/v8.0/" + posts_ids[u] + "?fields=username&access_token=" + inst_access_token).then(function (response) {
response.text().then(function (text) {
alert(text);
});
});
}
and
for (var u = 0; u < posts_ids.length; u++) {
fetch("https://graph.instagram.com/" + posts_ids[u] + "?fields=username&access_token=" + fs_access_token).then(function (response) {
response.text().then(function (text) {
alert(text);
});
});
}
But then I get this error:
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "ARVMttFmcIAfwBTPdYcMEfQ"
}
}
Most likely, this is because I am trying to combine the access token from Instagram with the technology for working with Facebook and the access token received from Facebook with the technology for working with Instagram. So couldn't you please help me to find endpoint in Instagram Basic or Instagram Graph which allows to get usernames from posts of the OTHER users(especially through ids which I get with Hashtag Search/recent_media)? Or couldn't you help me to understand how to use it correctly? Because I am a beginner and may not know some details. Please, help me!
Unfortunately you can't. You can find the following under the Limitations section on the hashtag endpoints.
Ref: https://developers.facebook.com/docs/instagram-api/reference/hashtag/recent-media