Help with Posting to Facebook

Am about to rip all my hair out (well what little I have left that is), have been trying for about the last 4 hours to just post a simple message to Facebook.

but whatever I do just doesn’t seem to work

the current code I’m working with is (using build 2013.1137)

local onFaceTouch = function( event ) if event.phase == "release" then audio.play( clickSound ) local fbAppID = "XXXXXXXXXXXXXXX" local facebookListener = function( event ) if ( "session" == event.type ) then if ( "login" == event.phase ) then local scoreToPost = 99 local statusUpdate = "I've just scored " .. scoreToPost .. "!" facebook.request( "me/feed", "POST", { message = statusUpdate } ) end end end facebook.login( fbAppID, facebookListener, { "publish\_stream" } ) end end

with the following in the build.settings

settings = { orientation = { default = "portrait", supported = { "portrait", }, }, iphone = { plist = { UIApplicationExitsOnSuspend = false, CFBundleDisplayName = "My App", FacebookAppID = "XXXXXXXXXXXXXXX", CFBundleURLTypes = { { CFBundleURLSchemes = {"fbXXXXXXXXXXXXXXX",} } } } } }

when the button that is assigned to the main script is clicked it takes me to Facebook where it asks me

“My App would like to access your public profile an friend list”

click ok

then

“My App” would like to post to your friends on your behalf

click ok

then it takes me back to my app without posting anything to Facebook.

Click on the button with the code on a second time, it goes to facebook with the following error message “invalid sso_key parameter. the key “app” does not match any allowed bundle IDs”

for 4 hours I’ve been going round and round and just can’t get the f***ing thing to work!

does anyone have any ideas what is wrong, or a better way of doing it??

my sanity is on the line here!

Can you add this:

    elseif ( "request" == event.type ) then         -- event.response is a JSON object from the FB server         responseText.text = event.response         -- if request succeeds, create a scrolling list of friend names         if ( not event.isError ) then             local response = json.decode( event.response )             local data = response.data             for i=1,#data do                 local name = data[i].name                 print( name )             end         end     end    

after the:  if ( “session” == event.type ) then

block?

Then you can see if you’re getting errors or what ever response that Facebook is returning.  Just to make sure you are building with a bundle ID that matches what you have in the facebook developer portal (not a wildcard AppID/Profile)

I’ve figured the problem out, at some stage (god knows how) I have blocked access to the app from my personal Facebook profile. To fix it I had to logon and go to settings > apps > app you use, and then delete it from there.

When I next fired up my app it asked me the access questions again which I agreed to and now it happily posts away!

One problem I have tho is the way in which the posting to Facebook works.

When you click on the post to facebook button you dont get any feedback that a post has been made. I assumed some dialogue would come up or something, but not knowing that this wasn’t the case I kept hitting the button and ended up posting 30 times to my wall :slight_smile:

Is there a correct way of doing this??

As a work around I have used Facebook.dialogue to post but not too sure if this is a good way of doing it, but it works!!

 local onFaceTouch = function( event ) if event.phase == "release" then audio.play( clickSound ) -- listener for "fbconnect" events local function listener( event ) if ( "session" == event.type ) then -- upon successful login, request list of friends if ( "login" == event.phase ) then facebook.showDialog( "feed", { message="", name="I've just score " ..highScore .. "!", caption="See if you can beat me!", link="https://itunes.com/apps/myApp", picture="http://www.myApp.com/myApp.png" }) end elseif ( "dialog" == event.type ) then print( event.response ) end end -- first argument is the app id that you get from Facebook facebook.login( "XXXXXXXXXXXXXXX", listener ) end end

That’s why I wanted you to put the elseif event.type == “request” block in.  It’s where you would get the results of doing a facebook.request() call.

I did add the elseif event.type == “request” block, but nothing happen in corona, xcode simulator or on a device. That why I started doing some digging and figured out that I had somehow blocked access to the app.

I’m having an issue with the facebook.showDialog tho that I cant understand. For some reason the message part doesnt get past to facebook, so I have to put it in the name part

this doesnt work:

facebook.showDialog( "feed", { message="I've just score" ..highscore.."!", name="myApp",

but this does:

facebook.showDialog( "feed", { message="", name="I've just score " ..highScore .. "!",

I would of assumed that the message part was where the message to be posted to facebook should be??

Can you add this:

    elseif ( "request" == event.type ) then         -- event.response is a JSON object from the FB server         responseText.text = event.response         -- if request succeeds, create a scrolling list of friend names         if ( not event.isError ) then             local response = json.decode( event.response )             local data = response.data             for i=1,#data do                 local name = data[i].name                 print( name )             end         end     end    

after the:  if ( “session” == event.type ) then

block?

Then you can see if you’re getting errors or what ever response that Facebook is returning.  Just to make sure you are building with a bundle ID that matches what you have in the facebook developer portal (not a wildcard AppID/Profile)

I’ve figured the problem out, at some stage (god knows how) I have blocked access to the app from my personal Facebook profile. To fix it I had to logon and go to settings > apps > app you use, and then delete it from there.

When I next fired up my app it asked me the access questions again which I agreed to and now it happily posts away!

One problem I have tho is the way in which the posting to Facebook works.

When you click on the post to facebook button you dont get any feedback that a post has been made. I assumed some dialogue would come up or something, but not knowing that this wasn’t the case I kept hitting the button and ended up posting 30 times to my wall :slight_smile:

Is there a correct way of doing this??

As a work around I have used Facebook.dialogue to post but not too sure if this is a good way of doing it, but it works!!

 local onFaceTouch = function( event ) if event.phase == "release" then audio.play( clickSound ) -- listener for "fbconnect" events local function listener( event ) if ( "session" == event.type ) then -- upon successful login, request list of friends if ( "login" == event.phase ) then facebook.showDialog( "feed", { message="", name="I've just score " ..highScore .. "!", caption="See if you can beat me!", link="https://itunes.com/apps/myApp", picture="http://www.myApp.com/myApp.png" }) end elseif ( "dialog" == event.type ) then print( event.response ) end end -- first argument is the app id that you get from Facebook facebook.login( "XXXXXXXXXXXXXXX", listener ) end end

That’s why I wanted you to put the elseif event.type == “request” block in.  It’s where you would get the results of doing a facebook.request() call.

I did add the elseif event.type == “request” block, but nothing happen in corona, xcode simulator or on a device. That why I started doing some digging and figured out that I had somehow blocked access to the app.

I’m having an issue with the facebook.showDialog tho that I cant understand. For some reason the message part doesnt get past to facebook, so I have to put it in the name part

this doesnt work:

facebook.showDialog( "feed", { message="I've just score" ..highscore.."!", name="myApp",

but this does:

facebook.showDialog( "feed", { message="", name="I've just score " ..highScore .. "!",

I would of assumed that the message part was where the message to be posted to facebook should be??