FQL: get all posts on My wall - facebook-fql

Folks - can someone share some FQL (other other graph query) to show my how I can query my own wall to list out all the posts.
I've tried things like
SELECT post_id, message
FROM stream where source_id = me()
and created_time > 946684800 AND created_time < now()
but (obviously) it only shows my my own posts. however, if I remove the source_id=me() then it errors out and tells me I need to include an indexable column.
Edit - this seems to work...
SELECT message FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() ) order by updated_time desc
Could anyone help me out?

Related

FQL Query for Stream returns no status messages for Friends

I am trying use FQL to get status updates of all the users friends using FQL. The challenge I am having is that... while I DO get data for companies/Brands/People the user likes or follows ...I get NO data for the users friends… I can see the users stream on facebook and its loaded with posts… but when I run the queries I get nothing… following are the queries I have tried…
SELECT source_id, actor_id, post_id, message,description, comment_info.comment_count, like_info.like_count, created_time
FROM stream
WHERE filter_key IN ( SELECT filter_key FROM stream_filter WHERE uid = me() )
I have tried the above query with an additional AND clause in the nested query e.g ”type = ‘newsfeed’ / type = ' friendliest’
I have also tried…
SELECT type, source_id, share_count, permalink, description, post_id, actor_id, target_id, message, created_time
FROM stream
WHERE source_id in (SELECT uid1 FROM friend WHERE uid2=me())
I also added an AND clauses with various type e.g type ='56’
The following are the permissions granted to the assess token…
basic_info, create_note, export_stream, friends_status, photo_upload, public_profile, publish_actions, publish_checkins, publish_stream, read_stream, share_item, status_update, user_friends, video_upload
Baffling… I say... Baffling… please help…. Thanks
I think you switched the uid1 and uid2 fields in your friend subquery. You can try the following:
SELECT source_id, actor_id, post_id, message,description, comment_info.comment_count, like_info.like_count, created_time FROM stream WHERE source_id in (select uid2 from friend where uid1 = me()) and filter_key="app_2915120374" LIMIT 100
filter_key="app_2915120374" means "Status Updates".
Alternatively, you could use the Graph API liek this:
GET /me/friends?fields=statuses.limit(5)&since=1388530800&limit=500
will return you the last 5 status updates of your friends since 2014-01-01.

FQL Query: Get all posts and comments made to my stream by friends only

I am using the following FQL Query to all my friends from my friends list successfully:
SELECT uid2 FROM friend WHERE uid1 = me()
I'd like to use all of the uid2's returned to perform a second query (or just combine it into one big one !!!!) that grabs all comments, posts and messages on my news_feed by friends only.
Heres what I have so far that grabs friends and non-friends.
SELECT type, created_time, post_id, actor_id, message FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid = me())
I'm only concerned with grabbing content (messages and textual info) posted by friends only. If you have a query that could help that would be great. FYI I have already been to the FB stream table page.
Append your 1st statement as another where clause to your 2nd:
SELECT type, created_time, post_id, actor_id, message FROM stream
WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid = me())
AND actor_id IN (SELECT uid2 FROM friend WHERE uid1 = me())

Facebook Graph API: How can I search a specific user's statuses for a certain keyword?

I want to be able to search/filter a user's statuses for a certain keyword. I thought I could do something like this:
graph.facebook.com/_user_id_/statuses?q=term
Or even:
graph.facebook.com/_user_id_/search?q=term&type=status
But none of those work and I can't find any documentation on this. I know I can do it with FQL, but the statuses method of the Graph API would give me likes and comments to each status as well.
Any suggestions?
You can do this with FQL, it just takes a multiquery to get it done:
{
'posts_w_keyword': 'SELECT post_id, actor_id, message FROM stream WHERE source_id = me()
AND strpos(message, "keyword") > -1',
'post_comments': 'SELECT post_id, from_id, text FROM comment WHERE post_id IN
(SELECT post_id FROM #posts_w_keyword)',
'post_likes': 'SELECT post_id, user_id FROM like WHERE post_id IN
(SELECT post_id FROM #posts_w_keyword)'
}

How to get FQL Stream with full names

I would like to show stream data from FQL
fql?q=SELECT post_id, app_id, source_id, updated_time, created_time, filter_key,
attribution, actor_id, target_id, message, app_data, action_links,
attachment, impressions, comments, likes, place, privacy, permalink, xid,
tagged_ids, message_tags, description, description_tags, type
FROM stream WHERE filter_key in (
SELECT filter_key FROM stream_filter WHERE uid=me()
AND type='newsfeed')
but the problem is that that table doesn't have name of the users/pages, only ids.
Is there any way to get names to those results too? And not only actor_id, but also name for the people who has made comments.
Do I need to make multiquery and search against all those ids in the stream, and then fetch from user and page tables. And then loop those results for every single stream result, seems kind of heavy. Any easier way?
I'm not sure if there is a way to get all the users and pages in one go but you could run two separate queries that will return the users/pages and then performance an array merge with both sets of results.
Users
SELECT uid,name from user where uid in (SELECT source_id FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed'))
Pages
SELECT page_id,name from page where page_id in (SELECT source_id FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed'))
You can do it in following way :
NSString *query =
#"{"
#"'friends':'SELECT post_id,actor_id,target_id,message,created_time, likes, comment_info FROM stream WHERE source_id IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND created_time > 1 ORDER BY created_time DESC LIMIT 50',"
#"'friendinfo':'SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT actor_id FROM #friends)',"
#"}";
Once you will get result, store it into two arrays like this :
FBFriendsNewsArray =(NSArray *) [[[result objectForKey:#"data"]objectAtIndex:0]objectForKey:#"fql_result_set"];
FBFriendsInfoArray=(NSArray *) [[[result objectForKey:#"data"]objectAtIndex:1]objectForKey:#"fql_result_set"];
And while displaying Feed search for that user id (actor_id) in Friends info array. hope this will help.

Retrieve Curated set of Photos from a Page stream

I'm working on an awareness campaign for a nonprofit. We're asking people to upload photos of them holding a sign to the nonprofit's Facebook page. Since they don't show clearly on the timeline, we want to scrape these photos and display them on a page on the nonprofit's website.
Getting all the photos is easy. I'm using the following FQL to get them:
SELECT post_id, actor_id, message, attachment, place, created_time
FROM stream WHERE source_id = PAGE_ID and source_id <> actor_id
AND attachment.media <> '' AND created_time > 1338834720
LIMIT 50
The problem is, there are other photos that people are uploading to the website that we don't want featured in this gallery. What I'd like to do is further filter this result set so we only get photos the page or a page admin has liked or commented on. This is where I'm getting stuck.
When I convert this to a multi-query and feed the results of the query above into:
SELECT post_id FROM like WHERE user_id = PAGE_ID AND post_id IN (SELECT post_id FROM #query1)
I get an OAuth error that I can only query like for the logged in user. This happens even when authenticating as the app using the PHP SDK.
I've tried getting people to add a text string to their message when they post, but that's not happening. Some people are adding that string to photos the nonprofit doesn't want and the best photos in the nonprofit's eyes don't have that string in them.
Thanks for your help.
Ok, answered my own question.
I'm using this FQL multiquery via the PHP SDK to get the curated group of photos. I settled on a comment made my any page admin:
{
'activity':
"SELECT post_id FROM stream WHERE source_id = PAGE_ID
AND attachment.fb_object_type = 'photo' AND created_time > 1338834720
AND comments.count > 0 LIMIT 100",
'commented':
"SELECT post_id, text, fromid FROM comment
WHERE post_id IN (SELECT post_id FROM #activity)
AND fromid IN (SELECT uid FROM page_admin WHERE page_id = PAGE_ID)",
'accepted':
"SELECT post_id, actor_id, message, attachment, place, created_time, likes
FROM stream WHERE post_id IN (SELECT post_id FROM #commented)
ORDER BY likes.count",
'images':
"SELECT pid, src, src_big, src_small, src_width, src_height FROM photo
WHERE pid IN (SELECT attachment.media.photo.pid FROM #accepted)",
'users':
"SELECT name, uid, current_location, locale FROM user
WHERE uid IN (SELECT actor_id FROM #accepted)",
'pages':
"SELECT name, page_id FROM page
WHERE page_id IN (SELECT actor_id FROM #accepted)",
'places':
"SELECT name, page_id, description, display_subtext, latitude, longitude
FROM place WHERE page_id IN (SELECT place FROM #accepted)"
}
The live site is here: http://getwellgabby.org/show-us-a-sign. Lots of PHP on the back end to combine the results and using ThickBox for the photo display.
Try doing your queries as Batch Requests. You can „name” queries in there to reference their results in other queries, and you can specify different access tokens for each individual operation.