I am trying to pull the photos from a user's post within a group. Posts in a group seem to be either created as a 'photo' or 'status'.
I am able to pull the photos from a post within the group when it is created as a 'photo' using this:
SELECT attachment FROM stream WHERE post_id="<postid>"
But if the post was created as a 'status' this query doesn't return any data for the attachment.
Here is an example of a post created as a 'status' and what the results are. No data for attachment (photo) when I know there is a photo that goes with that post.
SELECT attachment, type, message, created_time FROM stream WHERE post_id = '<postid>'
{
"data": [
{
"attachment": {
"description": ""
},
"type": 308,
"message": "Ceramic wall hanging with mirror from Spain (6\"x8\") $5 pickup in SR",
"created_time": 1379101402
}
]
}
Is this a permissions thing or am I just not pulling from the correct table(s) for this type of post?
Thanks
Chris
Just saying that it works fine for me:
SELECT post_id, attachment, type, message, created_time FROM stream WHERE post_id="POST_ID"
POST_ID looking like: 481234567779150_559912345679366. The permissions I use are user_groups and user_friends.
{
"data": [
{
"post_id": "481234567779150_559912345679366",
"attachment": {
"media": [
{
"href": "https://www.facebook.com/photo.php?fbid=10123450&set=gm.5599123456789366&type=1&relevant_count=1",
"alt": "bla bla bla",
"type": "photo",
"src": "https://fbcdn-photos-f-a.akamaihd.net/hphotos-ak-prn1/1013188_102013456789034740_1177097408_s.jpg",
"photo": {
"aid": "65904234567838363",
"pid": "65904345678990795",
"fbid": "10202345678934740",
"owner": 1533245678910,
"index": 1,
"width": 1032,
"height": 581,
"images": [
{
"src": "https://fbcdn-photos-f-a.akamaihd.net/hphotos-ak-prn1/1013188_10123456789_1177097408_s.jpg",
"width": 130,
"height": 73
}
]
}
}
],
"name": "",
"caption": "",
"description": "",
"properties": [
],
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif",
"fb_object_type": "photo",
"fb_object_id": "65123456789090795"
},
"type": 308,
"message": "bla bla bla",
"created_time": 1373368884
}
]
}
Did you try your query in the Graph API Explorer? Can you give more information? What kind of group is it, secret, public? Is the user one of your friend? I personally tried with both public or private groups and friend or non-friend posts. Can you confirm this happens with other 308-type posts with a photo and on several groups?
Related
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
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.)
I'm trying to fetch all my facebook timeline posts throw the facebook Graph API.
I'm playing with the Graph Explorer and have an access token with this permissions: (user_posts, read_stream) but when i call the endpoint "/posts" or "/feed" in the graph-api, the statues i shared (not i created) on my timeline (friends public status that i shared) didn't return.
this is a screenshot from my timeline
any idea?
If you share another POST - status then I dont think there is a way that will show up in your feed. It will show up under the user's feed who originally shared it, under posts and sharedposts
But if you share a link then it will show up under your feed as shared_story
Example from my feed
{
"data": [
{
"id": "XXXXXXXX",
"from": {
"id": "XXXXXXXX",
"name": "XXXXXXXX"
},
"story": "Vrashabh Irde shared a link.",
"story_tags": {
"0": [
{
"id": "XXXXXXXX",
"name": "XXXXXXXX",
"type": "user",
"offset": 0,
"length": 13
}
]
},
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQAvV7MyLsxFjRDc&w=130&h=130&url=https%3A%2F%2Ftctechcrunch2011.files.wordpress.com%2F2015%2F05%2Fdave-goldberg.jpg%3Fw%3D560%26h%3D292%26crop%3D1&cfs=1&sx=1&sy=0&sw=292&sh=292",
"link": "http://tcrn.ch/1GR0HU3",
"name": "Dave Goldberg, SurveyMonkey CEO, Dies Unexpectedly",
"caption": "tcrn.ch",
"description": "Silicon Valley and the wider world of technology are mourning the very sudden death of Dave Goldberg, a long time entrepreneur and investor, CEO of..",
"icon": "https://www.facebook.com/images/icons/post.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/XXXXXXXX/posts/XXXXXXXX"
},
{
"name": "Like",
"link": "https://www.facebook.com/XXXXXXXX/posts/XXXXXXXX"
}
],
"privacy": {
"value": "ALL_FRIENDS",
"description": "Your friends",
"friends": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "shared_story",
"created_time": "2015-05-03T14:45:09+0000",
"updated_time": "2015-05-03T14:45:09+0000",
"is_hidden": false,
"subscribed": true
}
This is from what I know, I dont see any documentation that says otherwise, good to have someone from Facebook comment here or you should probably raise a bug if this is not intended.
I need to retrieve wall posts from Facebook for a given account, but I'm only interested in posts that contain a photo. Is there a way to add such a filter to a Facebook graph api query? Something like:
https://graph.facebook.com/DigitasLBiNL?fields=feed&type=photo
The facebook data contains a type property which comes back as photo, so I would think this would be possible, but I haven't had any luck going through the facebook sdk documentation or tinkering around.
I know I could do the filtering myself, but I'd prefer to be able to keep the paging property that facebook returns.
The edges
/{user_id}/home (https://developers.facebook.com/docs/graph-api/reference/v2.1/user/home#read)
/{user_id}/feed (https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed#read)
should (as per documentation) both be able to take a filter paramenter, containing filter keys from the stream_filter FQL table (https://developers.facebook.com/docs/reference/fql/stream_filter/).
If I run the FQL
select name, value, type, filter_key from stream_filter where uid=me()
I get the following result:
{
"data": [
{
"name": "News Feed",
"value": null,
"type": "newsfeed",
"filter_key": "nf"
},
{
"name": "Status Updates",
"value": 2915120374,
"type": "application",
"filter_key": "app_2915120374"
},
{
"name": "Photos",
"value": 2305272732,
"type": "application",
"filter_key": "app_2305272732"
},
{
"name": "Links",
"value": 2309869772,
"type": "application",
"filter_key": "app_2309869772"
},
{
"name": "Pages",
"value": null,
"type": "public_profiles",
"filter_key": "pp"
},
{
"name": "Video",
"value": 2392950137,
"type": "application",
"filter_key": "app_2392950137"
},
{
"name": "Notes",
"value": 2347471856,
"type": "application",
"filter_key": "app_2347471856"
},
{
"name": "Groups",
"value": 2361831622,
"type": "application",
"filter_key": "app_2361831622"
}
]
}
So, if I choose app_2305272732 as filter key for the photos, I am able to run the follwoing Graph API request successfully:
/me/home?filter=app_2305272732&limit=3
This gives me the three most recent photo posts from my newsfeed.
You want to do this for User/Page feeds (Pages are not supported for filtering according to the docs at https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed#read), so I tried this:
/me/feed?filter=app_2305272732&limit=3
Unfortunately, this doesn't return only photo posts, at least for me. So I think this is a bug in the Facebook Graph API.
According to
https://developers.facebook.com/docs/graph-api/reference/stream-filter/
you can use the type filter with value photo
Using the Facebook graph API I can get a post that looks like this:
{
"id": "774345031_10153960483905032",
"from": {
"id": "774345031",
"name": "Ben Davis"
},
"story": "Ben Davis likes a photo.",
"story_tags": {
"0": [
{
"id": "774345031",
"name": "Ben Davis",
"offset": 0,
"length": 9,
"type": "user"
}
]
},
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2014-03-25T20:47:39+0000",
"updated_time": "2014-03-25T20:47:39+0000"
}
How can I get the mentioned photo?
You could try the following FQL query:
select pid, object_id, images from photo where pid in (select attachment.media.photo.pid from stream where post_id="774345031_10153960483905032")
For sure this is only working for Posts whih contain a photo reference. Be sure to gather the read_stream permission beforehand.