I'm doing a FQL query to get posts from a user:
{
"feeds": "SELECT type, actor_id, target_id, app_data, action_links, permalink, post_id, viewer_id, created_time, updated_time, source_id, message, description, attachment FROM stream WHERE filter_key = 'owner' AND source_id = <userId> AND is_hidden = 0 LIMIT 50"
}
For the most part, the results are great. However, if the result contains a post about the user "liking" something, how can I determine what was "liked"?
For example:
{
"type": null,
"actor_id": <userId>,
"target_id": null,
"app_data": [
],
"action_links": null,
"permalink": "",
"post_id": "<postId>",
"viewer_id": <userId>,
"created_time": 1369109320,
"updated_time": 1369109320,
"source_id": <userId>,
"message": "",
"description": "<user name> likes a status.",
"attachment": {
"description": ""
}
}
Which status?
Or:
{
"type": null,
"actor_id": <userId>,
"target_id": null,
"app_data": [
],
"action_links": null,
"permalink": "",
"post_id": "<postId>",
"viewer_id": <userId>,
"created_time": 1367029922,
"updated_time": 1367029922,
"source_id": <userId>,
"message": "",
"description": "<user name> likes a link.",
"attachment": {
"description": ""
}
}
Which link?
Do I need to do a multi-part query to get the extra data from a different table?
Why is the target_id always null?
This is a long standing bug, that hasn't been fixed for reasons unknown
https://developers.facebook.com/bugs/522743067756848
There is actually no efficient way to do it in the API.
<postId> = <userid_pId>
The way via Facebook UI would be https://www.facebook.com/userid/posts/pId
I've opened a new bug report but I highly doubt it will be fixed.
https://developers.facebook.com/bugs/648986871793611
Related
I hope to retrieve the info from Facebook inbox through the open API but failed.
I try to run the url in Graph API explorer
481315825357933?fields=attachment
Result is:
{
"error": {
"message": (#100) Unknown fields: attachment.,
"type": OAuthException,
"code": 100
}
}
Then I also run the FQL:
SELECT message_id, thread_id, author_id, body, created_time, viewer_id, attachment FROM message WHERE thread_id = 481315825357933
And got the result as:
{
"data": [
{
"message_id": "481315825357933_1435213395",
"thread_id": "481315825357933",
"author_id": "10153118278408579",
"body": Print it!,
"created_time": 1435213395,
"viewer_id": "1595482814036523",
"attachment": [
]
},
{
"message_id": "481315825357933_1435213454",
"thread_id": "481315825357933",
"author_id": "10153118278408579",
"body": Print it.,
"created_time": 1435213454,
"viewer_id": "1595482814036523",
"attachment": {
"media": [
],
"name": ,
"caption": ,
"description": ,
"properties": [
],
"fb_object_type": ,
"fb_object_id": "",
"icon": https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif,
"tagged_ids": [
]
}
}
]
}
Is the attachment info forbidden from Facebook API?
Thanks beforehand.
There's an attachments edge on the message level: /{message-id}/attachments
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.
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?
Facebook just notified me about "July 2013 Breaking Changes". There is one related to my app.
Deprecating 'comments' field from 'stream' FQL table
We are deprecating the 'comments' field from 'stream' FQL table. Please select the 'comment_info' column to fetch the 'can_comment' and 'comment_count' fields (formerly called 'can_post' and 'count'), and use the comment table directly to retrieve the list of comments.
In our app we are using query like this :
SELECT post_id, message, likes.count, comments.count, comments.comment_list FROM stream
WHERE source_id=me() AND actor_id=me() LIMIT 500
and receive response like this :
{
"data": [
{
**"post_id": "100002510712421_451594341600919",**
"message": "text",
"likes": {
"count": 1
},
"comments": {
"count": 2,
"comment_list": [
{
"fromid": 100001228089363,
"time": 1367073822,
"text": "text",
"text_tags": [
],
"id": "100002510712421_451594341600919_1181882",
"likes": 0,
"user_likes": false,
"post_fbid": 452073094886377
},
{
"fromid": 100000020227797,
"time": 1367173047,
"text": "text",
"text_tags": [
],
"id": "100002510712421_451594341600919_1183852",
"likes": 0,
"user_likes": false,
"post_fbid": 452790081481345
}
]
}
},
....
ok now try to fetch info from 'comment' table using given post_id
SELECT id, text, time, fromid FROM comment WHERE
post_id='100002510712421_451594341600919'
{
"data": [
]
}
The response is empty
Can anybody come up with solution? We really need it!
your query looks just fine, are you sure that this post_id exists and you have permission to read it?
SELECT id, text, time, fromid FROM comment WHERE
post_id='125909647492772_502974003098530'
returns
{
"data": [
{
"id": "502974003098530_78616446",
"text": "saugeil!",
"time": 1364309881,
"fromid": 526559276
}
]
}
I'veI run into the same issue.
Surprisingly, I was able to fix it by using only last part of the post_id, i.e.: '451594341600919' instead of '100002510712421_451594341600919'. But it works only sometimes and in your case doesn't work at all.
Adding the LIMIT option to an FQL causes MORE results to return than without the LIMIT.
For an example:
SELECT post_id, actor_id, message,description,type FROM stream WHERE source_id = me()
returns 4 results:
{ "data": [
{
"post_id": "1458319848_4164228991531",
"actor_id": 1458319848,
"message": "Oh happy days!",
"description": null,
"type": 46
},
{
"post_id": "1458319848_4081409841104",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan and Or Karlinsky are now friends.",
"type": null
},
{
"post_id": "1458319848_4076275592751",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan changed her Interested In.",
"type": null
},
{
"post_id": "1458319848_4075703458448",
"actor_id": 100001179537125,
"message": "",
"description": null,
"type": 237
}]}
But using:
SELECT post_id, actor_id, message,description,type FROM stream WHERE source_id = me() LIMIT 9
returns 5 results:
{"data": [
{
"post_id": "1458319848_4164228991531",
"actor_id": 1458319848,
"message": "Oh happy days!",
"description": null,
"type": 46
},
{
"post_id": "1458319848_4081409841104",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan and Or Karlinsky are now friends.",
"type": null
},
{
"post_id": "1458319848_4076275592751",
"actor_id": 1458319848,
"message": "",
"description": "Caroline Natan changed her Interested In.",
"type": null
},
{
"post_id": "1458319848_4075703458448",
"actor_id": 100001179537125,
"message": "",
"description": null,
"type": 237
},
{
"post_id": "1458319848_4069875152744",
"actor_id": 100000876758120,
"message": "",
"description": null,
"type": 237
}]}
Of course this DOESN'T MAKE ANY SENSE!
Am I missing something here? if so, what? Also I've read this, I didn't see anything regarding the problem described here.
Thanks in advance.
The article you linked to actually addresses this issue:
You might notice that the number of results returned is not always equal to the “limit” specified. This is expected behavior. Query parameters are applied on our end before checking to see if the results returned are visible to the viewer. Because of this, it is possible that you might get fewer results than expected.
Which basically means that facebook filters the results after it executes the query.
In your example, in the first query, there's an implicit limit, say 5. Out of these 5 results, 1 is filtered out because of visibility restrictions and you get 4.
In the second query, the server gets 10 results, filters 5 of them out based on visibility and returns 5 to you.