Hey, Yeah, I think I have run into this before. The ''friends'' call on a User actually calls ''@session.post(''facebook.friends.get'')'' So you always get the friends of the user for the current session. I kinda think it should blow up with an Exception. In order to be able to @source.friends_with?(@dest) you will need to have a facebook session setup for @source. Does that make sense? Am I following you? CC"ing the list so that all can enjoy. Dave On Feb 11, 2008 7:03 PM, William Thomas <wthomas989 at yahoo.com> wrote:> > Hi Dave - thank you for the quick response! I appreciate you discussing this > with me and I hope that I don''t have the wrong idea about how Facebooker is > supposed to work. > > Per bi-directional that is not exactly what I am saying. Is seems as though > both of those calls should return true, as we are both friends. Using the > pure api (in the test console) that is indeed what happens. > > I took a peek at the source code to Facebooker and saw that the > friends_with? calls "friends.map{|f| f.to_i}.include?(user_or_id.to_i) ". > This is fine when the source is the current session, but not so good when > the destination is not the current user. > > Here is a snippet of my code: > ________________________________ > src_id = params[:src_id] > > return if src_id.nil? || src_id.empty? > > @source = Facebooker::User.new(src_id) > @dest = @facebook_session.user > > @dest_to_src_are_friends = @dest.friends_with?(@source) > @src_to_dest_are_friends = @source.friends_with?(@dest) > > which yields the following in my view > > Source: Noah (friend) > Dest: Bill (me) > > Is source friends with dest? false > Is dest friends with source? true > ________________________________ > > > > > > ----- Original Message ---- > From: David Clements <digidigo at gmail.com> > To: Bill <wthomas989 at yahoo.com> > Sent: Monday, February 11, 2008 2:24:15 PM > Subject: Re: Facebooker development > > Hey Bill, > > Facebooker is actively being developed. We are on our way to 1.0 and > Mike has a book coming out very soon. > > What do you mean by are_friends? not being bi-directional? Do you > have a session for each user and one returns true and the other > doesn''t? > > Dave > > On Feb 11, 2008 6:37 AM, Bill <wthomas989 at yahoo.com> wrote: > > Is this still being actively developed? I am at a point where I need to > decide between facebooker & rfacebook. I like the way that facebooker is > "more ruby" but have already found a bug (in are_friends? not being > bi-directional). I am capable of submitting patches, etc, but am wondering > if it is worth spending time on instead of rfacebook. > > > > > > > > Thanks, > > > > Bill > > > > > ________________________________ > Never miss a thing. Make Yahoo your homepage.
Hello list! I hope this is an appropriate topic. I understand what is happening here and am not sure if there is an easy answer, especially given the four goals listed on the Readme. It seems as though there is a mismatch between the functionality the Facebook REST API provides and what Facebooker is attempting to do by "rubyist-ing" it. As I have not gone too deep with the Facebooker plugin as of yet this may be the only example but I believe it is a good one and something that warrants more discussion. The question I have is, should Facebooker provide all of the functionality that the Facebook REST api does? In this case, should you ensure that a call " user1.friends_with?(user2) " provides the same output as "friends.areFriends( user1, user2 ) "? Since Facebook allows you to swap user1 & user2 and get the same results I (personally) would expect the same from an API wrapper. If that is the case it may be as easy to fix as changing the method: def friends_with?(user_or_id) friends.map{|f| f.to_i}.include?(user_or_id.to_i) end TO def friends_with?(user_or_id) results = session.post(''facebook.friends.areFriends'', :uids1 => self.uid, :uids2=> user_or_id.to_i ) #ok , i decided i dont want to write the rest of this :) end ----- Original Message ---- From: David Clements <digidigo at gmail.com> To: William Thomas <wthomas989 at yahoo.com> Cc: facebooker-talk at rubyforge.org Sent: Monday, February 11, 2008 9:23:21 PM Subject: Re: Facebooker development Hey, Yeah, I think I have run into this before. The ''friends'' call on a User actually calls ''@session.post(''facebook.friends.get'')'' So you always get the friends of the user for the current session. I kinda think it should blow up with an Exception. In order to be able to @source.friends_with?(@dest) you will need to have a facebook session setup for @source. Does that make sense? Am I following you? CC"ing the list so that all can enjoy. Dave On Feb 11, 2008 7:03 PM, William Thomas <wthomas989 at yahoo.com> wrote:> > Hi Dave - thank you for the quick response! I appreciate you discussing this > with me and I hope that I don''t have the wrong idea about how Facebooker is > supposed to work. > > Per bi-directional that is not exactly what I am saying. Is seems as though > both of those calls should return true, as we are both friends. Using the > pure api (in the test console) that is indeed what happens. > > I took a peek at the source code to Facebooker and saw that the > friends_with? calls "friends.map{|f| f.to_i}.include?(user_or_id.to_i) ". > This is fine when the source is the current session, but not so good when > the destination is not the current user. > > Here is a snippet of my code: > ________________________________ > src_id = params[:src_id] > > return if src_id.nil? || src_id.empty? > > @source = Facebooker::User.new(src_id) > @dest = @facebook_session.user > > @dest_to_src_are_friends = @dest.friends_with?(@source) > @src_to_dest_are_friends = @source.friends_with?(@dest) > > which yields the following in my view > > Source: Noah (friend) > Dest: Bill (me) > > Is source friends with dest? false > Is dest friends with source? true > ________________________________ > > > > > > ----- Original Message ---- > From: David Clements <digidigo at gmail.com> > To: Bill <wthomas989 at yahoo.com> > Sent: Monday, February 11, 2008 2:24:15 PM > Subject: Re: Facebooker development > > Hey Bill, > > Facebooker is actively being developed. We are on our way to 1.0 and > Mike has a book coming out very soon. > > What do you mean by are_friends? not being bi-directional? Do you > have a session for each user and one returns true and the other > doesn''t? > > Dave > > On Feb 11, 2008 6:37 AM, Bill <wthomas989 at yahoo.com> wrote: > > Is this still being actively developed? I am at a point where I need to > decide between facebooker & rfacebook. I like the way that facebooker is > "more ruby" but have already found a bug (in are_friends? not being > bi-directional). I am capable of submitting patches, etc, but am wondering > if it is worth spending time on instead of rfacebook. > > > > > > > > Thanks, > > > > Bill > > > > > ________________________________ > Never miss a thing. Make Yahoo your homepage.____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080211/bd3462a0/attachment-0001.html
William- Facebooker aims to provide all the functionality of Facebook''s API. I don''t understand your concern though. user1.friends_with?(user2) should return the same result as user2.friends_with(user1), which maps directly to the Facebook call. Is there something I''m missing? I''m not sure what you mean by "rubyist-ing". We are returning objects instead of XML that you would have to manually parse. This would be the case if an API wrapper was well designed in any object oriented language. Shane On Feb 11, 2008 11:04 PM, William Thomas <wthomas989 at yahoo.com> wrote:> > Hello list! I hope this is an appropriate topic. I understand what is > happening here and am not sure if there is an easy answer, especially given > the four goals listed on the Readme. > > It seems as though there is a mismatch between the functionality the > Facebook REST API provides and what Facebooker is attempting to do by > "rubyist-ing" it. As I have not gone too deep with the Facebooker plugin as > of yet this may be the only example but I believe it is a good one and > something that warrants more discussion. > > The question I have is, should Facebooker provide all of the functionality > that the Facebook REST api does? In this case, should you ensure that a call > " user1.friends_with?(user2) " provides the same output as > "friends.areFriends( user1, user2 ) "? Since Facebook allows you to swap > user1 & user2 and get the same results I (personally) would expect the same > from an API wrapper. > > If that is the case it may be as easy to fix as changing the method: > > def friends_with?(user_or_id) > > friends.map{|f| f.to_i}.include?(user_or_id.to_i) > end > > TO > > def friends_with?(user_or_id) > results = session.post(''facebook.friends.areFriends'', :uids1 => > self.uid, :uids2=> user_or_id.to_i ) > #ok , i decided i dont want to write the rest of this :) > end > > > ----- Original Message ---- > From: David Clements <digidigo at gmail.com> > > To: William Thomas <wthomas989 at yahoo.com> > Cc: facebooker-talk at rubyforge.org > Sent: Monday, February 11, 2008 9:23:21 PM > Subject: Re: Facebooker development > > Hey, > > Yeah, I think I have run into this before. The ''friends'' call on a > User actually calls > ''@session.post(''facebook.friends.get'')'' > > So you always get the friends of the user for the current session. I > kinda think it should blow up with an Exception. > > In order to be able to @source.friends_with?(@dest) you will need to > have a facebook session setup for @source. > > > Does that make sense? Am I following you? > > CC"ing the list so that all can enjoy. > > Dave > > > > > On Feb 11, 2008 7:03 PM, William Thomas <wthomas989 at yahoo.com> wrote: > > > > Hi Dave - thank you for the quick response! I appreciate you discussing > this > > with me and I hope that I don''t have the wrong idea about how Facebooker > is > > supposed to work. > > > > Per bi-directional that is not exactly what I am saying. Is seems as > though > > both of those calls should return true, as we are both friends. Using the > > pure api (in the test console) that is indeed what happens. > > > > I took a peek at the source code to Facebooker and saw that the > > friends_with? calls "friends.map{|f| f.to_i}.include?(user_or_id.to_i) ". > > This is fine when the source is the current session, but not so good when > > the destination is not the current user. > > > > Here is a snippet of my code: > > ________________________________ > > src_id = params[:src_id] > > > > return if src_id.nil? || src_id.empty? > > > > @source = Facebooker::User.new(src_id) > > @dest = @facebook_session.user > > > > @dest_to_src_are_friends = @dest.friends_with?(@source) > > @src_to_dest_are_friends = @source.friends_with?(@dest) > > > > which yields the following in my view > > > > Source: Noah (friend) > > Dest: Bill (me) > > > > Is source friends with dest? false > > Is dest friends with source? true > > ________________________________ > > > > > > > > > > > > ----- Original Message ---- > > From: David Clements <digidigo at gmail.com> > > To: Bill <wthomas989 at yahoo.com> > > Sent: Monday, February 11, 2008 2:24:15 PM > > Subject: Re: Facebooker development > > > > Hey Bill, > > > > Facebooker is actively being developed. We are on our way to 1.0 and > > Mike has a book coming out very soon. > > > > What do you mean by are_friends? not being bi-directional? Do you > > have a session for each user and one returns true and the other > > doesn''t? > > > > Dave > > > > On Feb 11, 2008 6:37 AM, Bill <wthomas989 at yahoo.com> wrote: > > > Is this still being actively developed? I am at a point where I need to > > decide between facebooker & rfacebook. I like the way that facebooker is > > "more ruby" but have already found a bug (in are_friends? not being > > bi-directional). I am capable of submitting patches, etc, but am wondering > > if it is worth spending time on instead of rfacebook. > > > > > > > > > > > > Thanks, > > > > > > Bill > > > > > > > > > ________________________________ > > Never miss a thing. Make Yahoo your homepage. > > > ________________________________ > Looking for last minute shopping deals? Find them fast with Yahoo! Search. > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk > >-- http://shanesbrain.net | http://crimsonjet.com | http://myfitbuddy.com
I think you want to be using session.check_friendship instead of user.friends_with?. # Given an array like: # [[userid, otheruserid], [yetanotherid, andanotherid]] # returns a Hash indicating friendship of those pairs: # {[userid, otheruserid] => true, [yetanotherid, andanotherid] => false} # if one of the Hash values is nil, it means the facebook platform''s answer is "I don''t know" def check_friendship(array_of_pairs_of_users) uids1 = [] uids2 = [] array_of_pairs_of_users.each do |pair| uids1 = pair.first uids2 = pair.last end post(''facebook.friends.areFriends'', :uids1 => uids1, :uids2 => uids2) end -Shane On Feb 11, 2008 11:04 PM, William Thomas <wthomas989 at yahoo.com> wrote:> > Hello list! I hope this is an appropriate topic. I understand what is > happening here and am not sure if there is an easy answer, especially given > the four goals listed on the Readme. > > It seems as though there is a mismatch between the functionality the > Facebook REST API provides and what Facebooker is attempting to do by > "rubyist-ing" it. As I have not gone too deep with the Facebooker plugin as > of yet this may be the only example but I believe it is a good one and > something that warrants more discussion. > > The question I have is, should Facebooker provide all of the functionality > that the Facebook REST api does? In this case, should you ensure that a call > " user1.friends_with?(user2) " provides the same output as > "friends.areFriends( user1, user2 ) "? Since Facebook allows you to swap > user1 & user2 and get the same results I (personally) would expect the same > from an API wrapper. > > If that is the case it may be as easy to fix as changing the method: > > def friends_with?(user_or_id) > > friends.map{|f| f.to_i}.include?(user_or_id.to_i) > end > > TO > > def friends_with?(user_or_id) > results = session.post(''facebook.friends.areFriends'', :uids1 => > self.uid, :uids2=> user_or_id.to_i ) > #ok , i decided i dont want to write the rest of this :) > end > > > ----- Original Message ---- > From: David Clements <digidigo at gmail.com> > > To: William Thomas <wthomas989 at yahoo.com> > Cc: facebooker-talk at rubyforge.org > Sent: Monday, February 11, 2008 9:23:21 PM > Subject: Re: Facebooker development > > Hey, > > Yeah, I think I have run into this before. The ''friends'' call on a > User actually calls > ''@session.post(''facebook.friends.get'')'' > > So you always get the friends of the user for the current session. I > kinda think it should blow up with an Exception. > > In order to be able to @source.friends_with?(@dest) you will need to > have a facebook session setup for @source. > > > Does that make sense? Am I following you? > > CC"ing the list so that all can enjoy. > > Dave > > > > > On Feb 11, 2008 7:03 PM, William Thomas <wthomas989 at yahoo.com> wrote: > > > > Hi Dave - thank you for the quick response! I appreciate you discussing > this > > with me and I hope that I don''t have the wrong idea about how Facebooker > is > > supposed to work. > > > > Per bi-directional that is not exactly what I am saying. Is seems as > though > > both of those calls should return true, as we are both friends. Using the > > pure api (in the test console) that is indeed what happens. > > > > I took a peek at the source code to Facebooker and saw that the > > friends_with? calls "friends.map{|f| f.to_i}.include?(user_or_id.to_i) ". > > This is fine when the source is the current session, but not so good when > > the destination is not the current user. > > > > Here is a snippet of my code: > > ________________________________ > > src_id = params[:src_id] > > > > return if src_id.nil? || src_id.empty? > > > > @source = Facebooker::User.new(src_id) > > @dest = @facebook_session.user > > > > @dest_to_src_are_friends = @dest.friends_with?(@source) > > @src_to_dest_are_friends = @source.friends_with?(@dest) > > > > which yields the following in my view > > > > Source: Noah (friend) > > Dest: Bill (me) > > > > Is source friends with dest? false > > Is dest friends with source? true > > ________________________________ > > > > > > > > > > > > ----- Original Message ---- > > From: David Clements <digidigo at gmail.com> > > To: Bill <wthomas989 at yahoo.com> > > Sent: Monday, February 11, 2008 2:24:15 PM > > Subject: Re: Facebooker development > > > > Hey Bill, > > > > Facebooker is actively being developed. We are on our way to 1.0 and > > Mike has a book coming out very soon. > > > > What do you mean by are_friends? not being bi-directional? Do you > > have a session for each user and one returns true and the other > > doesn''t? > > > > Dave > > > > On Feb 11, 2008 6:37 AM, Bill <wthomas989 at yahoo.com> wrote: > > > Is this still being actively developed? I am at a point where I need to > > decide between facebooker & rfacebook. I like the way that facebooker is > > "more ruby" but have already found a bug (in are_friends? not being > > bi-directional). I am capable of submitting patches, etc, but am wondering > > if it is worth spending time on instead of rfacebook. > > > > > > > > > > > > Thanks, > > > > > > Bill > > > > > > > > > ________________________________ > > Never miss a thing. Make Yahoo your homepage. > > > ________________________________ > Looking for last minute shopping deals? Find them fast with Yahoo! Search. > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk > >-- http://shanesbrain.net | http://crimsonjet.com | http://myfitbuddy.com