How do I read mentions in fb api? - facebook

When I get a certain status in "/{status id}" api call, I get the message stripped from the mentions. How can I read the mentions?
Thanks

the field message_tags will give an array of mentioned users/pages in that post
Example:
"message_tags": {
"13": [
{
"id": "92689703737",
"name": "Tumblr",
"type": "page",
"offset": 13,
"length": 6
}
]
}

Related

Get Facebook page rating comments

I would like to retrieved comments from a page rating.
I'm getting page ratings from endpoind GET https://graph.facebook.com/v15.0/21[...]58/ratings?fields=created_time,has_rating,has_review,open_graph_story,rating,recommendation_type,review_text,reviewer
I get an array of rating object, with this rating for example:
{
"created_time": "2021-11-06T04:20:20+0000",
"has_rating": false,
"has_review": true,
"open_graph_story": {
"id": "21[...]58",
"message": "Lorem ipsum",
"start_time": "2021-12-26T21:14:02+0000",
"type": "sellers.rates",
"data": {
"recommendation_type": "positive",
"review_text": "Lorem ipsum",
"is_hidden": false,
"language": "fr",
"seller": {
"id": "54[...]12",
"title": "LOREM",
"type": "place",
"url": "https://facebook.com/lorem"
},
"has_review_update": false
}
},
"recommendation_type": "positive",
"review_text": "Lorem ipsum",
"reviewer": {
"name": "John Doe",
"id": "56[...]60"
}
}
Then, I'm trying to get comments from this review by requesting GET https://graph.facebook.com/v15.0/54[...]12_21[...]58/comments
But I get this error:
{
"error": {
"message": "Unsupported get request. Object with ID ' 54[...]12_21[...]58' 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": "Av[...]fN"
}
}
In the other hand, this request working fine with a "classic" post.
Does that means ratings are not concidered as a post ?
How can I get comments from rating ?
https://developers.facebook.com/docs/graph-api/reference/recommendation/
The Graph API docs do not mention any comments endpoint/edges for a single recommendation, so I assume it is not possible to get them.
Compare the docs to the page post docs: https://developers.facebook.com/docs/graph-api/reference/page-post/#edges

How can I get all photos in one post in a page using Graph API?

For example this graph
https://graph.facebook.com/audi/posts?access_token=[ACCESS TOKEN]&fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&since=2016-10-14T17:54:17+0000&limit=1
will give you this result(after replace ACCESS TOKEN with your access token ) :
{
"data": [
{
"id": "96585976469_10153772437221470",
"message": "Take a night tour of Capitol Hill with the #AudiRS7. #AudiDuel",
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/14680669_10153772435521470_6025374941796908984_n.jpg?oh=3654e74f79914c9bb0fa596ce8434c46&oe=589E82B4",
"link": "https://www.facebook.com/audi/photos/a.101113351469.101662.96585976469/10153772435521470/?type=3",
"name": "Photos from Audi USA's post",
"type": "photo",
"icon": "https://www.facebook.com/images/icons/photo.gif",
"created_time": "2016-10-14T17:54:17+0000",
"from": {
"name": "Audi USA",
"id": "96585976469"
},
"object_id": "10153772435521470"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=1476467657&access_token=[ACCESS TOKEN]&__paging_token=[ACCESS TOKEN]&__previous=1",
"next": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=2016-10-14T17\u00253A54\u00253A17+0000&access_token=[ACCESS TOKEN]&until=1476467657&__paging_token=[ACCESS TOKEN]"
}
}
and this is the link of the post
https://www.facebook.com/audi/posts/10153772437221470
it gave me just the first one photo but I need all photos in this post
attachments is the field you are looking for.
(Seems not officially documented, perhaps because those aggregate posts are special. But Graph API Explorer suggests it as one of the available fields.)

page-id/notifications returns an empty array

I'm writing a desktop application using Facebook SDK .NET. This app must do somethink for every post, comment or message sent to a Facebook page. I'm using the page-id/notifications API command:
page-id/notifications?fields=id,title,unread,application,from,message,object&limit=250
This command returns correct unseen count in summary section but data array is empty:
{
"data": [
],
"summary": {
"unseen_count": 2,
"updated_time": "2016-02-05T14:53:10+0000"
}
}
If someone write a new wall post on the page or send a private message to the page, unseen_count is updated but data array is always empty. If someoune write a comment to an exisiting wall post unseen_count is updates and data array is populated with a comment notification (only this type of notification are added to data array):
{
"data": [
{
"id": "notif_XXXXXXXXXXXXXXX_XXXXXXXXXXXXXXXX",
"title": "yyyyy yyyyyyy commented on his post.",
"unread": 1,
"application": {
"link": "https://www.facebook.com/games/?app_id=xxxxxxxxxxx",
"name": "Feed Comments",
"id": "1967xxxxxxx"
},
"from": {
"name": "Mxxxx Sxxxxxx",
"id": "1020xxxxxxxxxxxxx"
},
"object": {
"created_time": "2016-02-05T14:52:32+0000",
"message": "ABCDEFGHILMNOPQRSTUVZ",
"id": "36xxxxxxxxxxxx0_546xxxxxxxxxxx0"
},
"to": {
"name": "Ixxxxxxx",
"id": "36xxxxxxxxxxxxx"
}
}
],
"paging": {
"previous": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"next": "xxxxxxxxxxxxxxxxxxxx
},
"summary": {
"unseen_count": 3,
"updated_time": "2016-02-05T14:55:23+0000"
}
}
Is it an API bug or there is something wrong in my API request?
I CANNOT use real time notification.
Thanks
Marco

How To Find Out What A User "Liked" Facebook API

I'm currently calling the facebook me/home edge to get the users home feed. In the results I might get an entry like the JSON posted below.
My question is, when I get an entry like that where the user's friend ".. likes a link." How do I find out what link they liked? I'm trying to get the title and URL, but can't seem to figure out how. I've try just about every option using facebook's graph explorer.
Ideally, I would like that information to be returned when I made the /me/home request. I tried adding "attachments" to the fields parameter, but that didn't work.
{
actions=({
link="https://www.facebook.com/10154950234790111/posts/323892414481111";name=Comment;
});
comments={
};
"created_time"="2015-01-02T23:18:16+0000";from={
id=10154950234790453;name="Brian Joe";
};
id="10154950234790453_3238924144862222";
likes={
};
privacy={
value="";
};
story="Brian Joe likes a link.";
"story_tags"={
0=({
id=10154950234790111;
length=14;
name="Brian Joe";
offset=0;
type=user;
});
};
type=status;
"updated_time"="2015-01-02T23:18:16+0000";
}
This is a long standing bug in Facebook, probably older than two years.
https://developers.facebook.com/bugs/648986871793611/
https://developers.facebook.com/bugs/522743067756848/
I and many others have given up trying to repro this for Facebook Support.
You can give it a go if you want by reporting it to https://developers.facebook.com/bugs
Ideally Facebook should be inserting the object target in the story_tags like this
{
"story": "phwd likes Moët & Chandon.",
"story_tags": {
"0": [
{
"id": "13608786",
"name": "phwd",
"offset": 0,
"length": 17,
"type": "user"
}
],
"24": [
{
"id": "38995979792",
"name": "Moët & Chandon",
"offset": 24,
"length": 14,
"type": "page"
}
]
},
"id": "13608786_10101895322580287",
"created_time": "2015-01-03T17:35:51+0000"
},
Where this object
"24": [
{
"id": "38995979792",
"name": "Moët & Chandon",
"offset": 24,
"length": 14,
"type": "page"
}
]
Would instead be something like
"24": [
{
"id": "event_id",
"name": "Name of event",
"offset": 24,
"length": 14,
"type": "event"
}
]
So it ends up really being a feature request.

How do you retrieve the "Place" field of a Facebook Graph Post object?

I am trying to retrieve the "Place" field of a Facebook Graph Post object from a Facebook friend. After obtaining an access token with the friends_status and read_stream permissions, I request from the Graph API like so:
http://graph.facebook.com/[user_id]_[post_id]
What is returned are some of the fields described in the Graph API docs for Post:
{
"id": "1164358582_2458311174854",
"from": {
"name": "Joe Blo",
"id": "1164358582"
},
"message": "Is pretty bummed today",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
},
{
"name": "Like",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
}
],
"type": "status",
"application": {
"name": "Facebook for Android",
"id": "350685531721"
},
"created_time": "2011-11-20T03:23:04+0000",
"updated_time": "2011-11-20T12:12:49+0000",
"comments": {
"data": [
{
"id": "1164358582_2458311174852_2962531",
"from": {
"name": "Sue Candy",
"id": "1056617421"
},
"message": "OMG I'm so sorry!!!",
"created_time": "2011-11-20T03:25:06+0000"
}
],
"count": 1
}
}
This is all fine and dandy, except for the fact that when I see this Post within my Facebook stream, it also shows a location accompanying the post:
9 hours ago near El Reno, OK
I expected the El Reno, OK Place object returned as a field within this Post, but I don't see it.
In the Facebook Graph API Explorer, I've tried enabling almost every permission and I am not seeing any difference in the response (no "Place" field returned). Am I going about this incorrectly?
Not 100% sure but I think you can only get the "place" info if it is of type "checkin". I totally get where you are coming from, I wondered about that myself.
https://developers.facebook.com/tools/
Try the Graph API Explorer Tool if you haven't already looked at it.