Hi everyone,
Looking for a little bit of help.
What is the best way to post a score from an app to facebook?
Many thanks in advance.
[import]uid: 6762 topic_id: 11465 reply_id: 311465[/import]
Hi everyone,
Looking for a little bit of help.
What is the best way to post a score from an app to facebook?
Many thanks in advance.
[import]uid: 6762 topic_id: 11465 reply_id: 311465[/import]
[code]
local callFacebook = function()
local facebookListener = function( event )
if ( “session” == event.type ) then
– upon successful login, update their status
if ( “login” == event.phase ) then
local gameScore = 123456
gameScore = tostring( gameScore )
local theMessage = “just scored a " … gameScore … " playing an awesome game.”
facebook.request( “me/feed”, “POST”, {
message=theMessage,
name=“Download This Awesome Game to Compete with Me!”,
caption="Think you can beat my score of " … gameScore … “? I dare you to try!”,
link=“http://link-to-your-app-website-or-itunes-page”,
picture=“http://link-to-90x90-image” } )
end
end
end
facebook.login( “FACEBOOK APP ID”, facebookListener, { “publish_stream” } )
end
callFacebook()
[/code] [import]uid: 68741 topic_id: 11465 reply_id: 41586[/import]
Hi all,
Is there any reason why my code isn’t working for posting onto facebook.
local function callFacebook()
local facebookListener = function( event )
if ( "session" == event.type ) then
-- upon successful login, update their status
if ( "login" == event.phase ) then
local gameScore = tostring( score )
local theMessage = "just scored " .. gameScore .. " playing level " .. \_G.currentlevel .. "."
facebook.request( "me/feed", "POST", {
message=theMessage,
name="Download Sky Balloon to compete!",
caption="Think you can beat my score of " .. gameScore .. "?",
link="http://itunes.apple.com/gb/app/sky-balloon/id444988620?mt=8",
picture="http://www.georgecrawford.co.uk/apps/skyballoon90.png" } )
end
end
end
facebook.login( "139122219775879", facebookListener, { "publish\_stream" } )
end
facebook\_btn:addEventListener( "touch", callFacebook )
Note that isn’t my AppID on facebook, but the correct number of random digits.
Thanks
George [import]uid: 26801 topic_id: 11465 reply_id: 42855[/import]
Have you all got;
[lua]local facebook = require(“facebook”)
local json = require(“json”)
local tableView = require(“tableView”)[/lua]
in your apps?
And the json and tableView files in your project folder as well?
Peach
[import]uid: 52491 topic_id: 11465 reply_id: 43156[/import]
Hi Peach,
Thanks for the reply. I haven’t got the facebook declared in the main.lua but do have it in the project folder.
I thought that I read you didn’t need it in the latest version of corona, I’m not able to check for a week or so now, but will get back either way.
Thanks,
George
ps. Sorry about the cheeky twitter post!! [import]uid: 26801 topic_id: 11465 reply_id: 43159[/import]
Hey George,
No worries on the Twitter post; others do it too and it isn’t a problem at all 
As to Facebook - you say you have it in your folder? If you have a facebook.lua file you MUST DELETE IT. It is added during the build now.
You want to require facebook, TableView and json - but only have the TableView and json files in your folder - NO facebook.lua file.
Make sense?
[import]uid: 52491 topic_id: 11465 reply_id: 43199[/import]
Yeah makes sense!
Sounds like I got the wrong end of the stick about which part of the facebook that is now built in!!
Thanks
George [import]uid: 26801 topic_id: 11465 reply_id: 43231[/import]
No worries George; Facebook has changed a few times lately (in how we post to it) so there’s still some conflicting information lurking around.
If you get stuck I have a tutorial on http://techority.com that covers this as well 
Peach [import]uid: 52491 topic_id: 11465 reply_id: 43391[/import]
Hi Peach,
Thanks for the support, got the facebook posting working now.
George [import]uid: 26801 topic_id: 11465 reply_id: 44927[/import]
Hi,
This post is very helpful. Doe anyone know if this is the same for android? Before I start working on it for Android, just want to be sure I am going down the right path.
Sure I can find it, but if anyone has a recent link about created the “facebook app id”…that would be great. Since it was mentioned that some old information is lurking around.
BTW, peach, I really like you website…I have referred to it many times over the last month or so =)
Thanks!
Paul [import]uid: 39506 topic_id: 11465 reply_id: 44954[/import]
Quick question about FACEBOOK logging out.
is it better to auto log out of facebook once a score has been submitted? If we logout the player it means that next time they must re-login to post their score which could become frustrating. However if we leave the player logged in then no other person using the same phone can post the score on their facebook page as it will automatically post on the previous users’ profile.
Just curious to know what you guys do… auto logout for multiple users OR leave logged in for convenience. [import]uid: 66228 topic_id: 11465 reply_id: 49279[/import]
jacques1, good question on the facebook logging out method, I’d be curious as well if anyone has a good solution for that.
I have another question: the code above is working for me, but as soon as I log in, it immediately posts to my profile and closes the popup without giving the user a chance to edit and approve the post. Every time I press the button after that, it just quickly brings up a blank popup, posts to my profile, and then closes.
Does anyone know how to have the window stay open and allow the user to view and approve the content of the post? I think that the current behavior that I’m getting would violate Facebook’s developer guidelines, because it is unexpected functionality, and users must approve posts to their walls. [import]uid: 63524 topic_id: 11465 reply_id: 54104[/import]