Facebook integration

Wondering if someone could help me out with some Facebook issues. I’m simply trying to post a message to the users’ wall. I have the Facebook app developer all set up with SSO.

here’s what I’m using. I got the “app requests” part to work when uncommented out.

[code]local function FacebookButton_Pressed ()
– first argument is the app id that you get from Facebook
facebook.login( “403XXXXXXXX”, listener )

facebook.request( “me/feed”, “POST”, {message = “This is a really cool game, you should play it.”} )
–[[
facebook.showDialog( “apprequests”, {
message = “This is a really cool game, you should play it.”
})
]]

print(“Just Made … a Facebook”)
return true

end

local FacebookButton_params = {
on = “GameRules/Facebook_out.png”,
onWidth = 37,
onHeight = 37,
off = “GameRules/Facebook_over.png”,
offWidth = 37,
offHeight = 37,
state = true,
callback = FacebookButton_Pressed
}

local FacebookButton = toggle.new( FacebookButton_params )
FacebookButton.x, FacebookButton.y = screenRight-48, screenTop+166
FacebookButton.xScale, FacebookButton.yScale = 1, 1
screenGroup:insert(FacebookButton)
–END FACEBOOK BUTTON

[code] [import]uid: 90878 topic_id: 29671 reply_id: 329671[/import]

Below is a clip of code I use on a button process.

[lua]function postChallenge()

facebook.showDialog( “feed”, {
message = “Come Compete!”,
link = “www.myWebsite.com”,
picture=“www.myWebSite.com/myImage.png”,
description=“Description of my app”
})

end[/lua]

What isn’t shown is that before the user even gets to this option the FB login event would of already had to been completed. With your current code flow you could end up firing the post to wall code before the login is complete. Keep in mind that network.request(which is what facebook api is, really) are asynchronous, so once it fires off your facebook.login command it immediately proceeds to the rest of your code block instead of waiting for the login to finish.

If you need to do the login and the post event at the same time you will want to put the posting to wall code in your FB listener event and have it fire off after a successful login.
[import]uid: 147305 topic_id: 29671 reply_id: 119087[/import]

Here is the code that i use below, it all seems to work perfectly, with exception to the message on line 5, this doesn’t seem to populate in the popup box, however everything else does - any ideas?

edit: thank you budershank for your snippet above!

[lua]function listener( event )
if ( “session” == event.type ) then
if ( “login” == event.phase ) then
facebook.showDialog( “feed”, {
message = “Testing”,
link = “www.mysite.com”,
picture=“www.mysite.com/images/shake.png”,
description=“Download My App!”
})
end
elseif ( “dialog” == event.type ) then
print( event.response )
end
end

– I have a button setup to call the below function
function shareFacebook()
facebook.login( “16*********”, listener,{“publish_stream”})
end[/lua] [import]uid: 62706 topic_id: 29671 reply_id: 120054[/import]

Ok, found out why the message field was not working, the showDialog function no longer supports messages to be configured.

It now works as I have changed line 4 to the following:

[lua] facebook.request( “me/feed”, “POST”,{[/lua] [import]uid: 62706 topic_id: 29671 reply_id: 120087[/import]

Here is the code that i use below, it all seems to work perfectly, with exception to the message on line 5, this doesn’t seem to populate in the popup box, however everything else does - any ideas?

edit: thank you budershank for your snippet above!

[lua]function listener( event )
if ( “session” == event.type ) then
if ( “login” == event.phase ) then
facebook.showDialog( “feed”, {
message = “Testing”,
link = “www.mysite.com”,
picture=“www.mysite.com/images/shake.png”,
description=“Download My App!”
})
end
elseif ( “dialog” == event.type ) then
print( event.response )
end
end

– I have a button setup to call the below function
function shareFacebook()
facebook.login( “16*********”, listener,{“publish_stream”})
end[/lua] [import]uid: 62706 topic_id: 29671 reply_id: 120054[/import]

Ok, found out why the message field was not working, the showDialog function no longer supports messages to be configured.

It now works as I have changed line 4 to the following:

[lua] facebook.request( “me/feed”, “POST”,{[/lua] [import]uid: 62706 topic_id: 29671 reply_id: 120087[/import]