Instagram: Graph API does not return id of user who commented - facebook-graph-api

I am using Facebook Graph v7.0 to access Instagram data.
I can get comments made on instagram media using the following query:
Request:
https://graph.facebook.com/v7.0/18132613492054980?fields=id,ig_id,caption,timestamp,owner,username,media_type,permalink,children,comments.limit(100){hidden,id,like_count,media,text,timestamp,user,username},comments_count&access_token
Response:
{
"id": "18132613492054980",
"ig_id": "2263043983231761272",
"caption": "Sprite",
"timestamp": "2020-03-12T06:51:27+0000",
"owner": {
"id": "17841430463493290"
},
"username": "jobyjohn123456",
"media_type": "IMAGE",
"permalink": "https://www.instagram.com/p/B9n8oM7nTt4/",
"comments": {
"data": [
{
"hidden": false,
"id": "18132938077057326",
"like_count": 0,
"media": {
"id": "18132613492054980"
},
"text": "Nice sprite \u0040yziaf__07",
"timestamp": "2020-03-12T06:52:27+0000",
"username": "zimba_birbal"
}
]
},
"comments_count": 2
}
In the response, I do not get the User Id of user who commented. It just includes the username of the commenter.
Though, I pass user in the query, the result does not include it.
Do I need any special permission to get user id of the user who commented in the comment response?

There is Facebook API "business discovery" to get the user details of other Instagram User.
API request:
https://graph.facebook.com/178430463490?fields=business_discovery.username(user_name_you_wantto_get_its_IgUserId){followers_count,media_count,username,ig_id}
Response:
We can pass the user name in that API request, then we will get the Instagram User Id.
The documentation says it has one limitation, this will not work for "age-gated Instagram Business IG Users" but I do not exactly know what it means. When I tested for both older Instagram account and new Instagram account (just recently created account) and this API is returning data for both.
When I tested for private Instagram account, it did not work so it seems this api works only for business account.
If that api does not work, there is one workaround. The following request help to get User Id using its username but I have not found any API documentation regarding this API. It looks like this is not a standard API and moreover it does not need any token.
https://www.instagram.com/user_name_you_wantto_get_its_IgUserId/?__a=1

Related

Google my business not fetching reviews correctly

I'm currently using Google's api for fetching reviews of a Google My Business Account. We do this for our clients, which have to enable oauth for us, so we can have an access token and a refresh token.
The response we get, has the following structure:
url: https://mybusiness.googleapis.com/v4/accounts/{account_id}/locations/{location_id}/reviews
{
"reviews": [
{
"reviewId": "some-id,
"reviewer": {
"profilePhotoUrl": "some-url",
"displayName": "Some Sample Name"
},
"starRating": "FOUR",
"comment": "Some long comment left by the user.",
"createTime": "2021-02-15T14:35:19.252Z",
"updateTime": "2021-02-15T14:35:19.252Z",
"reviewReply": {
"comment": "Some long reply by the business.",
"updateTime": "2021-03-04T16:49:32.973Z"
},
"name": "accounts/{account_id}/locations/{location_id}/reviews/{review_id}"
},
...
],
"averageRating": 4.5,
"totalReviewCount": 1312,
"nextPageToken": "some-page-token"
}
The problem is, for some set of clients, we are getting just an empty object (literally, we are receiving {} as the response body). We are not sure why this is happening, since we are able to see reviews on the client's web site, and we are not getting any error. We've refreshed tokens and refreshed tokens without any success.
I've tried posting a support ticket with GCP in order to get some guidance, but it seems that you don't get any help in this kind of issues if you don't have the right support plan.
Anyhow, any help on this issue (why is happening? can it be fixed? is it a setup problem? etc.) is very much appreciated.

Facebook API process shared object [duplicate]

I just tried through the Graph API Explorer with this path /v2.4/10153513872748291 and I've got this result:
{
"error": {
"message": "(#12) singular links API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12
}
}
But https://developers.facebook.com/docs/reference/api/post/ doesn't say anything about deprecation.
I'm not sure if I miss something, or there's another way to get info about an individual post.
Edit: v2.3 works, but v2.4 is the latest one.
Looks like you now need to the combination of the id of the user or page that made the post (or whose wall it is on), an underscore, and then the post id.
For your example post, 10153513872748291, that is made by a page Drama-addict, that has the id 141108613290 – so 141108613290_10153513872748291 will work.
And so does 788239567865981_10153513872748291, because 788239567865981 is the id of the user making the post.
Firstput userId underscore add postId /Likes to check Like status in facebook
userId_post_Id/Likes to fetch Likes Records
userId_post_Id/Comments to fetch Comments Records
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=303261006522998_751199848395776%2FLikes&version=v2.9
**In this link Right side Get Token indide GetAccessToken to select Permission**
303261006522998_751199848395776/Likes
303261006522998_751199848395776/Comments
{
"data": [
{
"id": "124778301449917",
"name": "Manisha Gera"
},
{
"id": "1680577265523548",
"name": "Rubi Sharma"
}
],
"paging": {
"cursors": {
"before": "MTI0Nzc4MzAxNDQ5OTE3",
"after": "MTY4MDU3NzI2NTUyMzU0OAZDZD"
}
}
}

How to get cover photo from a document created in a Facebook group?

I am using the graph API explorer trying to find the photo added as the cover photo of a created document in a facebook group.
I am using the api call graph/v2.8/{group-id}/docs to get all the documents, and that works. However, there are no fields from a single doc stating anything about a cover picture. when I get all the documents I get data such as:
{
"data": [
{
"can_delete": true,
"can_edit": true,
"created_time": "2017-01-22T12:13:39+0000",
"from": {
"name": "name",
"id": "someId"
},
"icon": "https://static.xx.fbcdn.net/rsrc.php/v3/y7/r/8zhNI-VGpiI.png",
"message": "some HTML-formatted message",
"revision": "revNr",
"subject": "subject",
"updated_time": "2017-01-23T10:08:46+0000",
"id": "someDocId"
}
]
}
Maybe it is possible to use the documentId in order to get the cover photo, but I don't seem to find the correct API call. Are there any special permissions I need to have as well? I am only using the user_managed_groups permission.

Facebook graph api. how to list all pages that my app is subscribed to?

So I am aware of how to check each page to get a list of all subscribed apps.
But I would like to get a list of all pages my app has real time update subscriptions for?
so i have tried this
https://graph.facebook.com/v2.5/$app_id/subscriptions?access_token=$app_token
but this just brings back basic info on the app.
I would like a list of pages that it has subscriptions to already?
Can anyone help?
This doesn't look to be possible.
Endpoint you're using - https://developers.facebook.com/docs/graph-api/reference/v2.8/app/subscriptions - is to get list of application webhooks (callback_url and type of changes), which are called subscriptions for some reason. It's not about pages that subscribed to this webhook (or this app in general).
Overall, even in https://developers.facebook.com/apps/ for your app, under e.g. Messenger tab, you will only see subset of all pages that subscribed to this app. The visible subset is limited by your facebook user account permissions, presumably only show pages that you're either Admin or Editor.
Therefore, if such call would be possible, it would be somehow tied to User Access Token as well, not only app token.
You can do this here: https://developers.facebook.com/tools/explorer
Once logged, you can click on right button and select "Get User Access Token". You will need at least manage_pages or pages_show_list permission to accomplish this.
Now, all you have to do is call this endpoint: /me/accounts.
It should list all subscribed pages on your app.
Hope it helps.
As per
https://developers.facebook.com/docs/facebook-login/access-tokens/#apptokens
it is possible (graph api):
GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
And then /<app_id>/subscriptions
which returns something like:
{
"data": [
{
"object": "application",
"callback_url": "https:...",
"active": true,
"fields": [
{
"name": "ads_rules_engine",
"version": "v2.9"
}
]
},
{
"object": "page",
"callback_url": "https://...",
"active": true,
"fields": [
{
"name": "leadgen",
"version": "v2.5"
}
]
}
]
}

Graph API Score with GET method can't return score field

I use Facebook SDK 4.2.0 Android to create the leader scoreboard for my game.
I post successfully my score with POST method at /me/scores graphPath:
{Response: responseCode: 200, graphObject: {"success":true}, error: null}
However, when I try to GET the score at /me/scores as well as /793295994100883/scores (793295994100883 is my APP ID), I didn't see my score in JSON result string.
{Response: responseCode: 200, graphObject: {"data":[{"user":{"id":"Facebook USER-ID","name":"Facebook USER-NAME"}}]}, error: null}
In https://developers.facebook.com/tools/explorer, It return my expected string when I get at /793295994100883?field=scores{score}
"scores": {
"data": [
{
"score": 1234,
"user": {
"name": "Facebook USER-NAME",
"id": "Facebook USER-ID"
}
}
]
},
"id": "793295994100883"
Please help with this issue. How can I get score with Facebook SDK?
Thanks!
Which version of the Graph API is your app using? If it's v2.4, you have to specify each field you want to retrieve.
Have a look at my answer here:
Facebook only returning name and id of user