POST score to Facebook

Hi I’ve been trying to post a score to Facebook using the Corona Facebook API, and the Facebook’s docs https://developers.facebook.com/docs/score/ but all I get is a blank Facebook screen. What I am missing? thanks

Could it be that I’m not using the /USER_ID/scores, what’s the difference with me/scores?
[lua]------------
–FB
local FBlistener

local FBappId = “myActualAppID”

local function FBonClick( event )
if(event.phase == “release”) then
facebook.login( FBappId, FBlistener, {“publish_actions”} )
end
end

function FBlistener( event )
if ( “session” == event.type ) then
if ( “login” == event.phase ) then
facebook.request( “me/scores”, “POST”, {score = 1} ) --score set to 1 just to test
end
elseif ( “request” == event.type ) then

if ( event.isError ) then
local response = event.response
local errorText = display.newText(response, 0, 0, font1, 20 )
errorText:setTextColor(7, 52, 63)
errorText.x = display.contentWidth / 2
errorText.y = 25
GUI:insert(errorText)

print(response)

end
end

end

local FBbutton = ui.newButton {
defaultSrc = “fb.png” , defaultX = “300” , defaultY = “50”,
onEvent = FBonClick,
id = “FBbutton”
}

FBbutton.x = display.contentWidth / 2
FBbutton.y = display.screenOriginY + buttonsYmove + buttonsYdif*3 -10
GUI:insert(FBbutton)[/lua] [import]uid: 10426 topic_id: 15825 reply_id: 315825[/import]

Not a direct answer to your question, but if you just need to post scores that thread might help…

http://developer.anscamobile.com/forum/2011/05/06/easy-twitter-integration

It shows an easier way to post to Twitter & Facebook, which does not require a separate login within the app and allows user to see/edit the message.

If I decide to add that feature, I’ll probably use that. Might worth taking a look… [import]uid: 10478 topic_id: 15825 reply_id: 58463[/import]

I’m not that great with FB stuff but is the:

facebook.request( " me/scores", “POST”, {score = 1} )

“me/scores” a valid Social Graph API call?

See: for a list of what things you can do with /me/…

http://developers.facebook.com/docs/reference/api/user/
[import]uid: 19626 topic_id: 15825 reply_id: 58474[/import]

Thanks :), but it’s not so easy if you want to POST scores: https://developers.facebook.com/blog/post/539 [import]uid: 10426 topic_id: 15825 reply_id: 58477[/import]

My previous reply was for PixelEnvision.

robmiracle, I tried doing facebook.request( “me”, “GET”) and then use the user.id given to do
facebook.request( “user.id/scores”, “POST”, {score = 1} ) but It wouldn’t work. I’m thinking this is the right approach though. I don’t know why I came up with me/scores :stuck_out_tongue:

[import]uid: 10426 topic_id: 15825 reply_id: 58478[/import]

I’m assuming that when you are talking about user.id you have a lua table “user” with a member “id”.

Did you put the code in like you have it or did you do this:

facebook.request( user.id …"/scores", “POST”, {score = 1} )

??? [import]uid: 19626 topic_id: 15825 reply_id: 58481[/import]

Yes I did. But I can’t really tell what’s going on since I don’t get any error messages to appear. At least I can’t see them. (newText, print)
To see the scores of my app I have no problem. I use:

[lua]local FBlistener

local FBappId = “actual AppID”

local function FBonClick( event )
if(event.phase == “release”) then
facebook.login( FBappId, FBlistener, {“publish_actions”} )
end
end
function FBlistener( event )
if ( “session” == event.type ) then
if ( “login” == event.phase ) then
facebook.request( FBappId…"/scores", “GET” )
end
elseif ( “request” == event.type ) then

if ( not event.isError ) then
local response = Json.Decode( event.response )
local data = response.data

local function showImage( event )
event.target.alpha = 0
GUI:insert(event.target)

event.target.xScale = 0.25
event.target.yScale = 0.25
transition.to( event.target, { alpha = 1.0 , xScale = 1, yScale = 1} )
end

for i=1,#data do
display.loadRemoteImage(“http://graph.facebook.com/”… data[i].user.id …"/picture",
“GET”,
showImage,
“friend”…i…".png",
system.TemporaryDirectory,
30,
50+30*i)

local scoreText = display.newText(data[i].score, 0, 0, font1, 20 )
scoreText:setTextColor(7, 52, 63)
scoreText.x = 150
scoreText.y = 80+30*i
GUI:insert(scoreText)
end

end – not event.isError
end

end

local myButton = ui.newButton {
defaultSrc = “fb.png” , defaultX = “300” , defaultY = “50”,
onEvent = FBonClick,
id = “myButton”
}

myButton.x = display.contentWidth / 2
myButton.y = display.screenOriginY + buttonsYmove + buttonsYdif*3
GUI:insert(myButton)[/lua] [import]uid: 10426 topic_id: 15825 reply_id: 58485[/import]

@cmontesino,

Thanks for the link, it appears a lot has been changed on FB since my first look… [import]uid: 10478 topic_id: 15825 reply_id: 58546[/import]

@cmontesino:

send me an e-mail here: willyj@meappsstudio.com. I’ll send you a sample facebook project that you can unload in the code exchange afterwards…
[import]uid: 66859 topic_id: 15825 reply_id: 58631[/import]

@cmontesino:

Did what I sent you work for you?

[import]uid: 66859 topic_id: 15825 reply_id: 58922[/import]

@MeApps,

Thanks for sending me your files, but Facebook is not allowing any app to post pre-filled messages to the wall.
http://developer.anscamobile.com/forum/2011/09/06/facebook-wall-posts-and-facebook-platform-policies-be-careful
http://developers.facebook.com/docs/reference/dialogs/feed/

That’s why I’m trying to use the scores API that we are supposed to use for, well, scores. If you wanted to tell people that the user just played the game I think we now have to use the new Open Graph Actions-Objects API.

So we(you too :S) are in step 1, again. Damn you FB!
PS. I guess it’ll be for the better though, people won’t complain about their friends posting new scores all the time :slight_smile: And I guess we’ll be listed in the Timeline along other big budget games(in the table of last games played), and we just ask permission to do this once :slight_smile: [import]uid: 10426 topic_id: 15825 reply_id: 58999[/import]

Hhhm,

I am not sure if that is true. NestMe has pre-filled messages that we are posting. We have this app in the app store currently:

http://itunes.apple.com/us/app/nestme-lite/id466992516?ls=1&mt=8

Check it out…

Willy J.

[import]uid: 66859 topic_id: 15825 reply_id: 59000[/import]

Have anyone managed to do this? [import]uid: 102088 topic_id: 15825 reply_id: 102517[/import]

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]

Thanks for the fast reply! I see what you’re doing there. Just using the easy post to feed.
But I was wondering if anyone have managed to get the post score to work. I would rather use this because it doesn’t post the score as a status update. The score get posted to your app. This (if im not mistaken) will generate feed and ticker stories, as well as timeline aggregations.

https://developers.facebook.com/docs/score/

Thanks! [import]uid: 102088 topic_id: 15825 reply_id: 102527[/import]

I decided to use open feint for online leaderboards and i am just using the facebook post as just a simple addition. As far as the score api goes, i have not seen anyone use it with corona and there is nothing in the example and corona documentation so there is a chance that it might not be useable with corona, ive noticed some api features that are available with the stock api, are not available with the corona version. I could be and hope i am wrong because this would be a nice feature to use in the future. Good Luck [import]uid: 126161 topic_id: 15825 reply_id: 102529[/import]

I think you need to request activites permissions inorder for it to work. Im going to try and get it going and will let you know how it goes… [import]uid: 118379 topic_id: 15825 reply_id: 106437[/import]

also be sure to check this out in the share your code section:

lib_facebook

it will allow you to test your code within the simulator which is super. No more guessing whats up. [import]uid: 118379 topic_id: 15825 reply_id: 106439[/import]

I’m a bit frustrated at the moment as I got twitter to post scores with a dialog to custom edit your post via webpopup direct url post, but facebook doesn’t allow you to pre-fill in a message for their url feed.

This solution doesn’t appear to allow you to edit what your posting, which I think is really important, does anyone have a solution? [import]uid: 88628 topic_id: 15825 reply_id: 118370[/import]

I’m having the same issue. If the score is passed as a string instead of an integer (as it’s supposed to be according to the Facebook docs) I was able to get the right response from Facebook (true) but the score doesn’t show up on the user’s wall or ticker. Could it be that Corona’s Facebook API doesn’t work with integers? I even tried passing event.token but not sure if that’s the app’s access token or the user’s access token.

Would be great if anyone at Ansca could take a look at this issue as posting scores to Facebook could be very useful to a lot of game developers. [import]uid: 10048 topic_id: 15825 reply_id: 126879[/import]