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?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ------------ --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) |
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...
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/.....
Thanks :), but it's not so easy if you want to POST scores: https://developers.facebook.com/blog/post/539
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 :P
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} )
???
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 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) |