Reputation: 216
Is it possible to get messages from specific user?
If I would like to get all messages where recipients are myself and x
I didn't find a way to create that kind of query, so is it possible?
Upvotes: 1
Views: 2066
Reputation: 5364
Now FQL don't have field author_id
, only originator
and snippet_author
. But this fields contain wrong data. For example, userA send me (userB) message: userA create thread. Anyway I see, that originator have me (userB).
Best way use recipients
:
SELECT recipients,snippet,object_id,updated_time,unread,unseen,thread_id FROM thread WHERE folder_id=0 AND recipients IN (userA_fid, userB_fid)
But it's also don't work and return empty data...
Upvotes: 0
Reputation: 786
var fbid = your_fbuid_here;
FB.api({
method: 'fql.query',
query: 'SELECT thread_id, author_id, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0) AND author_id = ' + fbid + ' ORDER BY created_time ASC LIMIT 1'
}, function ( threadresponse ) {
FB.api({
method: 'fql.query',
query: 'SELECT thread_id, body, author_id, created_time FROM message WHERE thread_id = ' + threadresponse[0].thread_id + ' ORDER BY created_time ASC'
}, function ( inboxresponse ) {
//do stuff here with results
});
});
or you can do this
var fbid =the _freind_fb_uid_here;
FB.api({
method: 'fql.query',
query: 'SELECT thread_id, body, author_id, created_time FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0) AND author_id = ' + fbid + ' ORDER BY created_time DESC'
}, function ( threadresponse ) {
//do stuff here with results
});
facebookfacebook-fqlfacebook-apifacebook-graph-apifacebook-fql-query
Upvotes: 1