How to get user from comment on page posts use feed - facebook

I got the comments list from the feed, but I could not get their user name and avatar, I used the graph explorer and there were no fields to retrieve the user information that was commented.
I tried, but it does not work.
{page_id}/feed?fields=id,comments{id,message,created_time}
Comment Id also doesn't support getting user information.
448052816017010_448055412683417/?fields=message
// My result
"data": [
{
"id": "448052816017010_448055412683417",
"message": "TYM TYM",
"created_time": "2019-06-24T07:20:22+0000"
}
] ...
Is there a way to get user or user id, or do I need to grant any permissions?

https://developers.facebook.com/docs/graph-api/reference/v3.3/comment
You need to ask for the correct field. id is just the id of the comment itself, not the id of the user. from would be the correct field. You have to use a Page Token of that Page, and i believe the App has to be live:
{page_id}/feed?fields=id,comments{id,message,created_time,from}
See this for additional information: Graph API: Cannot get "from" field in comment

Related

Missing attributes with Facebook Graph API Photo Node

I have an access token with the manage_pages scope. Using this token, I call the endpoint specified here (GET /{page-id}/photos?type=uploaded).
The result is for some reason lacking all attributes except id and created_time. This is a part of the response:
"data": [
{
"created_time": "2018-10-30T18:12:31+0000",
"id": "1172525292900120"
},
{
"created_time": "2018-10-30T18:10:08+0000",
"id": "1172524459566870"
}
]
The docs says that data should contain "A list of Photo nodes". Looking at the photo node docs, it seems they have exactly what you'd expect.
My app does not have the permission Page Public Content Access yet. But according to their App Review section, it isn't needed for accessing my own page's content. And then again, I wouldn't even be able to get a list of photos if I didn't have access to the page.
While you are testing your app and before you submit it for review, your app can only access content on a Page for which the following is true: The person who holds the admin role for the Page also holds an admin, developer, or tester role on the app.
Why am I missing some attributes in the Photo nodes?
I had to specify which fields to retrieve like this: GET /{page-id}/photos?type=uploaded&fields=images.

How to display "from" fields in comments via Facebook Graph API

I would like to find the id (app-scoped) for someone who has posted a comment on a public page.
For example, I get a list of recent posts/comments on the NY Times page via:
v2.11/nytimes/feed?fields=comments.limit(10){message,created_time,from},name,message,from&limit=2
The data returned looks like this:
"comments": {
"data": [
{
"message": "Wouldn’t know. Not paying $13/mo for this.",
"created_time": "2017-12-10T05:57:18+0000",
"id": "10151412260164999_10151414049324999"
}
],
There is no from field. The same is also true if I attempt to view the comment directly using it's id with
v2.11/10151412260164999_10151414049324999?fields=from,message,created_time
I have tried using the Facebook Graph API Explorer, using both my User Token, as well as an App Token.
Since v2.11 of the Graph API, you need a Page Token to get user data of comments: https://developers.facebook.com/docs/graph-api/changelog/version2.11#gapi-90
User information will not be included in GET responses for any objects owned by (on) a Page unless the request is made with a Page access token. This affects all nodes and edges that return data for objects owned by a Page.
In other words: You can only get user information if you manage the Page.
Edit: Since the latests update in the Graph API, you have to get the App reviewed and you must go through Business Verification or Individual Verification. (thanx #Guiman04)
Please check whether you are using the accessToken for the page you are trying to get data from, i had same issue, and was resolved by using the correct accessToken for the page.

How to get User's avatar after Facebook API was changed

I have an issue the relates with Facebook API. Before, I can use the graph api like that to get user avatar
//graph.facebook.com/giuliana.roeffero/picture?type=large
But now I got this issue
{
"error": {
"message": "(#803) Cannot query users by their username (giuliana.roeffero)",
"type": "OAuthException",
"code": 803
}
}
So now, I need to use the User ID instead of User Name, like this
//graph.facebook.com/100001473111658/picture?type=large
And my question is Can we get the User Avatar by User Name via Facebook API now? If not, how can I get the User Id by User Name?
You can´t get the username at all, it was removed from the API. The only way is to use the (App Scoped) ID, just as you mentioned in your question. So this is how you get the Avatar:
Authorize the User (with no additional permissions) to get his App Scoped ID
use https://graph.facebook.com/[User-ID]/picture to get his Avatar

Commenting on Facebook Page Ratings (Reviews) via Graph API

Long time lurker first time poster...
We are working with Facebooks API's to integrate into our web application and we are able to pull a Companies Page Rating via the {open_graph_story} parameter in the {page-id}/ratings section, however we cannot find a way to comment/reply to the rating. The documentation states:
"If a person has rated your page and a story has been generated, you can follow up with the person by posting to the story's comment node." (https://developers.facebook.com/docs/graph-api/reference/v2.0/page/ratings)
however when we pull the variables we retrieve no ID to reference for a comment. This is what we receive back from our authenticated account:
"data": [
{ "created_time": "2014-07-16T05:52:50+0000", "reviewer": { "id": "100000237096397", "name": "Romey Salazar" }, "rating": 5, "review_text": "Great job guys!!!!" } ],
Does anyone know how to retrieve the id for the rating itself so we can append a comment via API? Or some other way to reply/comment to a FB Page Rating?
Thanks!
When you have some ratings/review comments on your page and if you want to post comment to individual review comments as the Page Owner, you can follow the steps below.
1) Below request returns the json object of rating and reviews.
https://graph.facebook.com/v2.9/{YOUR_PAGE_ID}/ratings?field=open_graph_story&access_token={YOUR_PAGE_ACCESS_TOKEN}
The response json will contain ID field for each and every rating/review comments.
2) Using the ID, trigger the below request to post a comment on the rating as the Page Owner. You will need Page access token with manage_pages and publish_pages privilege.
https://graph.facebook.com/v2.9/{ID_OF_THE_RATING}/comments?message=Thanks for your rating&access_token={YOUR_PAGE_ACCESS_TOKEN}
These requests can be tested using Facebook Graph API Explorer
You need to request the open_graph_story field with the ratings endpoint. This will return the open_graph_story data which includes an id. You can then post to the comments endpoint of this story.
You have to make http get request on
https://graph.facebook.com/v2.9/{PageID}/ratings?fields=open_graph_story&access_token={PageAccessToken}
to get detailed response.
Make sure the parameter is "fields" not "field"

FQL query in Graph API explorer not returning all of the data in profile

I have created a test user for my facebook app and filled in the fields for name, profile picture, music, tv, movies, books, actvities and interests. The information is there and I can view it in the profile, but for some reasons in spite of having specified what appear to be the correct permissions, I cannot access this information even through the Grap API explorer when I am logged in as the user.
When I go to the Graph API explorer, go to the FQL tab and launch the following query I only get certain fields:
SELECT name,pic_big,music,tv,movies,books,email FROM user WHERE uid = me()
The response is:
{
"data": [
{
"name": "Aisha Bibi",
"pic_big": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/274348_100004159483336_574477135_n.jpg",
"music": "",
"tv": "",
"movies": "",
"books": "",
"email": "aisha_gjmodrm_bibi#tfbnw.net"
}
]
}
I generated the access token for this request by selecting the following user data permissions: email, user_activities, user_education_history, user_interests.
Could anybody tell me why it is failing to retrieve information for the user even though it is present on the profile, I have detailed the correct permissions(?) and I am logged in as them while accessing the Graph API explorer tool?
Thanks in advance :D
I am sorry - I did not read the documentation clearly enough it seems. In order to access the user's music and movies etc you need the user_likes permission. I hope this helps somebody!