Multiple requests to Facebook

If i request facebook with the following example code:

fb\_command = 'get\_friends'  
facebook.login( appId, listener, {"publish\_stream"} )  
  
fb\_command = 'get\_user\_info'  
facebook.login( appId, listener, {"publish\_stream"} )  

and inside the event phase login do:

if ( "login" == event.phase ) then  
 if fb\_command == 'get\_user\_info' then  
 facebook.request( "me" )  
 elseif fb\_command == 'get\_friends' then  
 facebook.request( "me/friends" )  
 end  
end  

it happens that the code facebook.request( "me/friends" ) will never be executed, because when execution arrives to that login phase the second request has already set fb\_command = 'get\_user\_info'

there are a way to register a listener for each request? Or do i need to implement some kind of semaphore to allow only one request at a time? [import]uid: 145589 topic_id: 29236 reply_id: 329236[/import]

[lua]facebook.login( appId, friendListener, {“publish_stream”} )
facebook.login( appId, userListener, {“publish_stream”} )

local function friendListener()
– do naughty things with friend request here
end

local function userListener()
–do naughty things with user request here
end[/lua]

No reason why you can’t have multiple FB listeners. You could probably shoe horn it into the same one but imo it would cause more complications then anything else. [import]uid: 147305 topic_id: 29236 reply_id: 117563[/import]

If you execute this code:

local function friendListener(event)  
 -- do naughty things with friend request here  
 if ( "session" == event.type ) then  
 if ( "login" == event.phase ) then  
 facebook.request( "me/friends" )  
 end  
 elseif ( "request" == event.type ) then  
 print('me/friends request')  
 end  
end  
   
local function userListener(event)  
 --do naughty things with user request here  
 if ( "session" == event.type ) then  
 if ( "login" == event.phase ) then  
 facebook.request( "me" )  
 end  
 elseif ( "request" == event.type ) then  
 print('me request')  
 end  
end  
  
facebook.login( appId, friendListener, {"publish\_stream"} )  
facebook.login( appId, userListener, {"publish\_stream"} )  

the only thing that will be printed is: print('me request')
what i think that happen is before the first facebook.login facebook.login( appId, friendListener, {"publish\_stream"} ) ends, the second one facebook.login( appId, userListener, {"publish\_stream"} ) register a new global listener to all facebook requests.
If that really happen, how can i use a different listener to each request? [import]uid: 145589 topic_id: 29236 reply_id: 117849[/import]

Err, just went through what I do and realized my example wasn’t spot on with what I actually do. Instead of doing two calls I sort of daisy chain them. I guess I got it confused with my regular network listeners. Sorry bout that!
[import]uid: 147305 topic_id: 29236 reply_id: 117873[/import]

Anybody has a solution, or do i really need to implement some kind of semaphore to allow only one request at a time? [import]uid: 145589 topic_id: 29236 reply_id: 118444[/import]