6

I have a facebook desktop app with some test users all having granted the stream_read & offline access permissions. I can easily retrieve posts to each users' stream & profile. What I cannot do easily is retrieve posts that a user has made to one of their friend's walls.

In fact, this used to work with a rather complex multiquery, but has stopped working now, or is working only intermittently...

Does anyone care to share their method if one exists or discuss what restrictions there might be to this type of complex querying?

simianarmy
  • 1,485
  • 10
  • 13

3 Answers3

2

I gave this a try and ran into the same problem I belive but perhaps I can help explain it a little more.

It might be something worth posting in the Facebook wiki talkpage and see if someone from Facebook can shed some light on it unless I'm missing something here.

Anywhere I put USER_ID would need to be filled in with the user you want to search as and F_ID1, F_ID2 are friends ...

FQL #1: should work (in theory)

  • First get a list of all your friends
  • then use that list in the IN clause of the next query
  • filter out to just posts made by the USER_ID
  • make sure the message isn't NULL

FQL #1: No posts are returned

{
"friends":"SELECT uid2 FROM friend WHERE uid1= USER_ID ",

"postsonfriendswall":"SELECT source_id, actor_id, target_id, message FROM stream WHERE source_id IN (SELECT uid2 FROM #friends) AND message != '' AND actor_id = USER_ID "

}

FQL #2: Posts are returned

Strangely however if you limit to just one friend (F_ID1), you will get back posts USER_ID made to their friends wall!

{
"friends":"SELECT uid2 FROM friend WHERE uid1= USER_ID ",

"postsonfriendswall":"SELECT source_id, actor_id, target_id, message FROM stream WHERE source_id IN (SELECT uid2 FROM #friends WHERE uid2 = F_ID1) AND message != '' AND actor_id = USER_ID "

}

FQL #3: No posts are returned

Yet, try to add another friend to the IN F_ID1 & F_ID2 ... no result again ...

{
"friends":"SELECT uid2 FROM friend WHERE uid1= USER_ID ",

"postsonfriendswall":"SELECT source_id, actor_id, target_id, message FROM stream WHERE source_id IN (F_ID1,F_ID2) AND message != '' AND actor_id = USER_ID "

}
Justin Jenkins
  • 26,590
  • 6
  • 68
  • 1,285
  • Hey Justin - thanks for the input - I want to be able to do a single query (nested or multiquery) per user - otherwise we are talking about N x N # queries depending on avg. # of friends per user. I will inquire at the facebook dev site & post an update if I get anywhere. – simianarmy Mar 21 '10 at 05:46
  • I'd be quite interested why I can't seem to get back more then one friend's posts at one time ... so please pass that on if you find out. A vote up on this answer if helpful would be appreciated too :) – Justin Jenkins Mar 21 '10 at 06:26
  • Hey Justin - check out my answer below & tell me if that worked out for you. – simianarmy Mar 23 '10 at 18:15
0

CORRECTION: After further testing, I found that this solution DOES NOT work 100%. It will return some but not all posts that you have made on other walls - I do not know what the limiting factor is - so I consider this an open question.

The partial solution: So, this is the FQL multiquery that generates the wall posts a user makes on friends' walls:

{"query1":"SELECT post_id FROM stream WHERE source_id IN (SELECT target_id FROM connection WHERE source_id = USER_ID)", 
 "query2":"SELECT actor_id, post_id, target_id, message FROM stream WHERE (actor_id = USER_ID) AND (post_id IN (SELECT post_id FROM #query1))"}

The 1st query does a nested select for all the "targets" belonging to a user (friends & apps?) & uses those as the source_id value for a stream query.
The 2nd query uses the post_id's returned from the 1st query to query the stream again this time with the actor_id attribute set to the user's id.

I don't know if ORDER or LIMIT clauses would help returning more recent queries or not - anyone care to confirm?

simianarmy
  • 1,485
  • 10
  • 13
0

At a minimum I found that I could use, with php:

$facebook->api("/<friend_uid>/feed") 

to get back exactly what's shown on a users wall. And you can page the query. Unfortunately you can't filter your query with the exception of targeting a friends wall by the shown above. However the API is darn slow and incurs A LOT more API calls than a Multiquery. Sad, but this seems to be the only option if you are running into a situation where you're not seeing all the posts you expect to see when using FQL (either a single FQL or a Multiquery).

Bug Logged on Facebook: If you have this problem to please please submit your feed back on this bug! http://bugs.developers.facebook.net/show_bug.cgi?id=11247

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
Rob K.
  • 519
  • 6
  • 16
  • Now I don't believe it's possible to use multiquery anymore as this is simply too much data for Facebook to consider returning in a single request. Like you, I resorted to querying for my posts on friends' walls, one friend at a time. With the average friend count at about 100 this would be fine, but some people have > 1K friends so obviously not an ideal solution. – simianarmy Dec 08 '10 at 04:50