Struggling to post to Facebook

Hi all,

I’m really struggling to post to Facebook from my app. When the button is tapped it gets me to log-in but then the message just fails to get posted.

I suspect that the problem isn’t with the code at the Corona end. But rather with how I have the App setup on the Facebook end. Unfortunately all the examples I’ve seen on posting from Corona seem to be before Facebook updated their developers section and so I’m struggling to compare the guide against what I am actually seeing.

Specifically the guide written by Peach Pellen here: http://corona.techority.com/2011/03/08/add-facebook-posting-to-your-corona-iphone-app/

Says the following:

“Then fill in the standard info such as your apps name, your email for support, etc. then under mobile and devices be sure to set your core settings to HTML 5 and NOT Native Application.”

But I can’t see anything like that.

I’d be very grateful for any help or assistance anyone can be. Better still a recent step-by-step guide would be awesome. [import]uid: 100713 topic_id: 33237 reply_id: 333237[/import]

Looking at the date of the blog post, it’s from over a year and a half ago. Facebook has certainly changed things since then.

can you get a screen shot of your FB settings for us to look at? [import]uid: 19626 topic_id: 33237 reply_id: 132112[/import]

I am just working on Facebook at the moment.

Here is what I have and seems to work when you call ‘shareFacebook()’

You would need to put your own facebook app id into the ‘sharefacebook’ function, and edit the details you are posting in the ‘onfacebooklogin’ function.
[lua]local facebook = require “facebook”

function listener( event )
if event.isError then
native.showAlert( “ERROR”, event.response, { “OK” } )
else
if event.type == “session” and event.phase == “login” then
onFacebookLogin()
elseif event.type == “request” then
local response = event.response
native.showAlert(“Facebook”, “Your score has been posted to your feed.”, {“Ok”})
end
end
end

function onFacebookLogin ()
facebook.request( “me/feed”, “POST”,{
message = “I scored 500 points!”,
link = “www.website.com”,
picture=“www.echoecho.es/images/shake.png”,
description=“Coming soon for iPhone & iPad!”})
end

function shareFacebook()
facebook.login( “APP ID GOES HERE”, listener,{“publish_stream”})
end[/lua] [import]uid: 62706 topic_id: 33237 reply_id: 132113[/import]

Not sure if you’re interested but you may want to have a look at our GGFacebook lib on the code-exchange and github. [import]uid: 119420 topic_id: 33237 reply_id: 132114[/import]

If I didn’t already have the Facebook post leftover from my last project, I would have used Glitch Games libs. You guys do a great job and I’ll be using your twitter lib in my next app. I’ll be sure to drop a mention in there for you guys :wink: [import]uid: 62706 topic_id: 33237 reply_id: 132115[/import]

Cool! Really appreciate the mention! [import]uid: 119420 topic_id: 33237 reply_id: 132116[/import]

Thanks guys so much for all this. I’ll take a look tonight and report back. Can I ask how you set it up at the Facebook end, as I’m thinking that this is likely to be the problem rather than my code (but it could be my code). OpenGraph and what I need to tell it about my mobile application is completely bamboozling me.

Once it’s all up and running I’m planning to share everything as a step-by-step process so that everyone can see how it works - well until Facebook changes it again. [import]uid: 100713 topic_id: 33237 reply_id: 132179[/import]

The Facebook end is pretty straight forward, for iOS you just need the bundle id and app id from iTunes connect and enable Facebook Login.

For Android you need your package name, the class name “com.ansca.corona.CoronaActivity” and the hash from your keystore ( http://stackoverflow.com/questions/12021771/what-does-mean-android-key-hash-in-native-android-app-section-in-fb-applicat ) and again enable Facebook login. [import]uid: 119420 topic_id: 33237 reply_id: 132182[/import]

Looking at the date of the blog post, it’s from over a year and a half ago. Facebook has certainly changed things since then.

can you get a screen shot of your FB settings for us to look at? [import]uid: 19626 topic_id: 33237 reply_id: 132112[/import]

I am just working on Facebook at the moment.

Here is what I have and seems to work when you call ‘shareFacebook()’

You would need to put your own facebook app id into the ‘sharefacebook’ function, and edit the details you are posting in the ‘onfacebooklogin’ function.
[lua]local facebook = require “facebook”

function listener( event )
if event.isError then
native.showAlert( “ERROR”, event.response, { “OK” } )
else
if event.type == “session” and event.phase == “login” then
onFacebookLogin()
elseif event.type == “request” then
local response = event.response
native.showAlert(“Facebook”, “Your score has been posted to your feed.”, {“Ok”})
end
end
end

function onFacebookLogin ()
facebook.request( “me/feed”, “POST”,{
message = “I scored 500 points!”,
link = “www.website.com”,
picture=“www.echoecho.es/images/shake.png”,
description=“Coming soon for iPhone & iPad!”})
end

function shareFacebook()
facebook.login( “APP ID GOES HERE”, listener,{“publish_stream”})
end[/lua] [import]uid: 62706 topic_id: 33237 reply_id: 132113[/import]

Not sure if you’re interested but you may want to have a look at our GGFacebook lib on the code-exchange and github. [import]uid: 119420 topic_id: 33237 reply_id: 132114[/import]

If I didn’t already have the Facebook post leftover from my last project, I would have used Glitch Games libs. You guys do a great job and I’ll be using your twitter lib in my next app. I’ll be sure to drop a mention in there for you guys :wink: [import]uid: 62706 topic_id: 33237 reply_id: 132115[/import]

Cool! Really appreciate the mention! [import]uid: 119420 topic_id: 33237 reply_id: 132116[/import]

Thanks guys so much for all this. I’ll take a look tonight and report back. Can I ask how you set it up at the Facebook end, as I’m thinking that this is likely to be the problem rather than my code (but it could be my code). OpenGraph and what I need to tell it about my mobile application is completely bamboozling me.

Once it’s all up and running I’m planning to share everything as a step-by-step process so that everyone can see how it works - well until Facebook changes it again. [import]uid: 100713 topic_id: 33237 reply_id: 132179[/import]

The Facebook end is pretty straight forward, for iOS you just need the bundle id and app id from iTunes connect and enable Facebook Login.

For Android you need your package name, the class name “com.ansca.corona.CoronaActivity” and the hash from your keystore ( http://stackoverflow.com/questions/12021771/what-does-mean-android-key-hash-in-native-android-app-section-in-fb-applicat ) and again enable Facebook login. [import]uid: 119420 topic_id: 33237 reply_id: 132182[/import]