Answer the question
In order to leave comments, you need to log in
Instagram API. How and what request do I need to make to get usernames from posts using their IDs?
I have two access tokens:
1. From Instagram Graph API: var fs_access_token which I get after logging in with Facebook;
2. From Instagram Basic Display: var inst_access_token;
So I have a collection of post id's that I get via ig_hashtag_search:
I also have 3 posts on my Instagram business account. And I'm trying to get the usernames of all these posts that I have in my collection with a single endpoint:
var posts_ids; //!= null;
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
});
});
}
{
"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"
}
}
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);
});
});
}
{
"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"
}
}
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);
});
});
}
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);
});
});
}
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "ARVMttFmcIAfwBTPdYcMEfQ"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question