I have a button in my app after each level to post the score and level name and link to the app on facebook and it works great, here is the code for it.
faceFunc is a listener that is attached to the facebook button in my app
[lua]–Facebook function
local faceListener = function (event)
if event.type == “session” then
if event.phase == “login” then
facebook.request( “me/feed”, “POST”, faceMessage )
end
end
end
local faceFunc = function ()
facebook.login(“myappid”, faceListener, {“publish_stream”} )
end[/lua]
now the facemessage variable is created when the game is finished so the score and level is correct when they go to post, here is the actual message post that is attached to the facemessage variable
[lua]faceMessage = {
name = “Word Search Craze”,
link = “http://3dreamsgaming.com/blog/?page_id=47”,
message = “I just finished the “…titLe…” puzzle in Word Search Craze for Android!”,
caption = "Can you beat my time? "…minSecTimer.text,
description = “Full description here, you can put what ever you want and it will show up under the caption”,
picture = “http://3dreamsgaming.com/publicftp/images/beatLevel.png”,
actions = json.encode( { name = “3 Dreams Gaming”, link = “http://www.3dreamsgaming.com” } )
}[/lua]
This will post a photo, i use a logo for our game, also will post a description, add a little link for our company site at the bottom and post the time it took and the puzzle they were on.
So to make this easier here is a blank template. and what you need to use facebook posting.
[lua]local facebook = require (“facebook”)
local json = require (“json”)
–Facebook function
local faceListener = function (event)
local faceMessage = {
name = “Put the name of your app here”
link = “put any link here to attach to the name”
message = “this is the message that will display in the message dialog box.”
caption = “put a caption here that will display under the name.”
description = “obvious, this will display under the caption”
picture = “put a link to a picture here to display as part of the post”
–Actions will put a json button down low with that ever name you want and a link , puts it next to the small facebook app logo that goes with the post if you added one when you created the page on facebook.
actions = json.encode ({ name = “put the name of the button here”, link = " put the link you want the button to go to here" })
}
–Checks for a login and if everything is good then it calls to post the faceMessage.
if event.type == “session” then
if event.phase == “login” then
facebook.request( “me/feed”, “POST”, faceMessage )
end
end
end
local faceFunc = function ()
facebook.login(“yourappid”, faceListener {“publish_stream”} )
end
–Button to activate the post to facebook
local facebutton = display.newRect (0, 0, 50, 50)
facebutton.x = display.contentWidth/2; facebutton.y = display.contentHeight/2
facebutton:addEventListener(“tap”, faceFunc)[/lua]
well that’s pretty much it, this is what works for me, with the message you done have to use all the table, if you wanna just post a message then just use message =, if u don’t wanna post a picture then don’t put it in there. This game is 1 week from release and has been testing by 50 people and they had no problem posting this prefilled message. Hope this helps. [import]uid: 126161 topic_id: 15825 reply_id: 102524[/import]