Not getting "from" attribute in facebook comments - facebook

I'm using facebook API v9.0 to get posts and comments associated with it using the page token.
The issue is such that I'm unable to get the 'from' attribute or in other words, the author of the comments in the response. I'm not sure what I'm missing here, please advice.
The cURL request is as below: 995833924237049 is the post_id
curl -i -X GET \
"https://graph.facebook.com/v9.0/995833924237049/comments?fields=from&access_token={access_token}"
The response is as below from Graph API Explorer:
{
"data": [
{
"id": "995833924237049_819251442244461"
},
{
"id": "995833924237049_998774397276335"
},
{
"id": "995833924237049_998772833943158"
},
{
"id": "995833924237049_998781380608970"
},
{
"id": "995833924237049_998776877276087"
},
{
"id": "995833924237049_998782583942183"
},
{
"id": "995833924237049_998781987275576"
},
...
]}
The permissions I have currently are as below:-
email
pages_show_list
pages_read_engagement
pages_manage_metadata
pages_read_user_content
pages_manage_posts

Related

How to get facebook comments of ads posts using Facebook Graph API

I am the admin of my companies Facebook page. I'm trying to get all the ads for the Facebook page using the Graph API. The access token that I use has the following permissions:
read_insights
manage_pages
ads_read
ads_managment
...
How can I get the comments below the ads posts?
This is what I tried using Graph API:
my_page_ID/ads_posts
What I get is this:
{
"data": [
{
"created_time": "2020-03-26T14:42:38+0000",
"message": "We have the best price. Please come to us!",
"id": "4353425346_5634563463622263"
},
{
"created_time": "2020-03-26T12:28:35+0000",
"message": "This is some add",
"id": "65464567_687456456"
},
{
"created_time": "2020-03-26T12:19:34+0000",
"message": "This is the message of the ad.",
"id": "123456789_463456534623"
},
{
"created_time": "2020-03-20T08:06:44+0000",
"id": "34534588605_358563733107"
},
{
"created_time": "2020-03-20T08:06:44+0000",
"id": "388533217888605_3586754538066441"
},
{
"created_time": "2020-03-20T08:06:44+0000",
"id": "34353417888605_5844534530"
},
{
"created_time": "2020-03-20T08:06:44+0000",
"id": "38854535405_230852376563421"
},
{
"created_time": "2020-03-20T08:06:18+0000",
"id": "382342345605_358677843899"
What I do not understand:
Why are most fields empty? Am I doint sth. wrong? Do I need more permissions?
How can I retriev all ads posts and not just a few?
How can I retriev the user comments below these posts?
Hope you can help me with this.
Easy peasy!
/{page-id}/ads_posts?include_inline_create=true
Includes all Ads Posts (Dark Posts)

Facebook graph api unable to get some properties like admin_notes, labels or custom_labels in comments listing

We are building an app that manage Facebook comments for page admins. When managing the comments, we want to know if there is any "admin_notes" or "custom_labels" that the page admin has previously applied on that specific owner of the comment.
I imagine the API is something like this:
https://graph.facebook.com/v3.3/45013343238491111/comments?order=reverse_chronological&fields=message,from{name,id,custom_labels,admin_notes,likes}&access_token=...
The api above should theoretically return list of comments made on a post, with their owners name, id, and custom_labels etc.
But the comment listing response is like this:
{
"data": [
{
"message": "sdfsdfsdf",
"from": {
"name": "Dora Chan",
"id": "23424292416969420",
"likes": {
"data": [
{
"name": "Page name",
"id": "XXXXXX",
"created_time": "2019-05-29T06:03:42+0000"
}
],
"paging": {
"cursors": {
"before": "Mzg5OTgwNzQ4MjcxNzU3",
"after": "Mzg5OTgwNzQ4MjcxNzU3"
}
}
}
},
"id": "450133432384921_450162525715345"
},
{....
Information like "page likes" is available. But information like admin_notes and custom_labels are not available.
Why is that so?
Note:
I am using page access Token. All page related permissions are granted:
manage_pages, pages_show_list, publish_pages, pages_messaging, public_profile
If I call graph API on that specific user directly, i.e. https://graph.facebook.com/v3.3/[userid]?fields=name,id,likes,custom_labels&access_token=...
The outcome is same, I can see only name, userid, likes, but I cannot see custom_labels

Facebook Messenger API: Send Message to commenter on page

I'm having problems using the messenger API with a page access token to send a message to a user who has commented on a post on the page. I've done the following:
Subscribed the page to a test app, which has a webhook monitoring the page 'feed' parameter.
The webhook callback gets a result similar to this structure when a person comments on a post on the page:
{
"entry": [{
"changes": [{
"field": "feed",
"value": {
"item": "comment",
"sender_name": SENDER,
"comment_id": COMMENT_ID,
"sender_id": SENDER_ID,
"post_id": POST_ID,
"verb": "add",
"parent_id": PARENT_ID,
"created_time": 1492159609,
"message": "hello"
}
}],
"id": PAGE_ID,
"time": 1492159609
}],
"object": "page"
}
I then call the messenger API with the SENDER_ID above by sending a POST request to https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN (as documented here) with the params:
recipient: {
id: '10158402684940316'
},
message: {
text: 'what up'
}
but I get the error: (#100) No matching user found.
Any ideas what I'm doing wrong here?
I've just found a simple api for this case. Just use Private Replies API
POST /v2.9/{COMMENT_ID}/private_replies

Permissions to get comments of post user is tagged in on facebook

I'm attempting to do some analysis of a user's Facebook data, so I'm attempting to collect as much as possible. Using the Facebook graph api, which permissions do I need to request in order to get the comments for a post the user is tagged in. If the post is on the user's wall, it isn't a problem, but if the user is tagged in a post on a friend's wall no comments are there, and the count is set to 0.
I'm making a request to //feed with what I believe to be a valid access token from my application. However, using the graph explorer tool from Facebook the same situation happens. I assume the problem is a permission I am missing, but can't seem to figure out which one I should add.
I'm currently requesting the following permissions:
friends_photos
friends_likes
friends_checkins
friends_status
user_photos
user_likes
user_checkins
user_status
read_mailbox
read_stream
{
"id": REDACTED,
"from": {
"name": REDACTED,
"id": REDACTED
},
"to": {
"data": [
{
"name": REDACTED,
"id": REDACTED
}
]
},
"message": REDACTED,
"message_tags": {
"121": [
{
"id": REDACTED,
"name": REDACTED,
"type": "user",
"offset": 121,
"length": 11
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2013-03-13T14:25:44+0000",
"updated_time": "2013-03-13T14:25:44+0000",
"comments": {
"count": 0
}

How to visuzlize facebook post

I have a post id (obtained from the Graph API), can I generate a URL which will display this post in Facebook's interface?
Seems there should be something like http://facebook.com/viewpost?postid=6666666666 ...
You want to manually construct a permalink given only the post ID?
The Graph API for a post ID returns the URLs the user should go to to comment on or like the post, assuming the viewing user has permission to do so.
Example:
GET http://graph.facebook.com/19292868552_10150189643478553?access_token={access token here}
Snipped some of the fields of the response, but you're looking for 'actions':
{
"id": "19292868552_10150189643478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
// removed fields from response
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Like",
"link": "https://www.facebook.com/19292868552/posts/10150189643478553"
},
{
"name": "Share",
"link": "http://networkedblogs.com/hGWk3?a=share"
}
],
// Snipped rest of response
In general, the format of a permalink seems to be:
https://www.facebook.com/{source id}/posts/{post object id}
(Source ID being the user or page ID where the post is)
You can't definitely reply on that URL format always being the same; the API response should be always accurate though