views:

50

answers:

2

My User table (mysql db on a other server) has a FaceBookId Column. How do i filter it by friends?

I mean

 Select * from User where FacebookId in SomeTypeOfGetFriends(of me ... the logged in user)

what's the best way? should I first get the friends in an array, then do a FacebookId IN (array) ?

OR:

For every user that logs on, I could do something like this: on the first page, when they log in, i could save all his/her friends, just ID-s in a table that looks like: ftbl(userloggedinfbid INT, friendsfbid INT). I would do this once, every time he loggs in. Then would do a join. But this way I would be storing connections between users, which facebook does already. Why should I re-store them?

I am not sure re-storing friendship-type-connections is even ok with FB.

A: 

I think you'd be better off looking at the PHP SDK and the new Graph API.

Once you've authenticated a user on your application, you can call the friends.getAppUsers API method to return friends, who also use the current application, of the currently logged in user. Example usage:

$friends = $facebook->api(array('method' => 'friends.getAppUsers'));
Martin Bean
A: 

First of all

I am not sure re-storing friendship-type-connections is even ok with FB.

Is totally ok. In fact, they even let you subscribe for real time updates on a user's friends. Not that I'm recommending you go this route.

Secondly, in my own applications, I'm doing exactly what you suggest. A big ol' IN() statement (combined with the API call Martin Bean posted). But you can also achieve these types of queries with temp tables, too.

Also, just as an FYI, you can't use an INT column type to store Facebook IDs, which are 64-bit integers. Go with VARCHAR or BIGINT.

Peter Bailey