So I’m having an issue with the Facebook API. It looks like I’m not throwing any errors, however when I try to make a new post to a user’s wall it is opening the Facebook App on my phone and telling me that “You have already authorized this application. Press continue”… This is true, but when I press continue, it doesn’t post anything it just takes me to my wall and completely forgets about the app. I"m using the same code that has been posted numerous times all over the forums and in example code. I have my facebook application setup properly with application ID, etc matching my app. Sometimes it will completely bypass the “You have already authorized this application” dialog and go straight to my wall… What am I doing wrong and is this even possible anymore? I just want to allow my users to make a post to their wall manually once a day by pressing a button…
My code:
[lua]f_sharegame = function()
– Contact Facebook –
–native.showAlert( “Error!”, event.errorMessage, { “OK” } )
local function listener( event )
if(“session” == event.type)then
if ( “login” == event.phase ) then
–[[
local attachment = {
name = “I’m playing my Game on my iPhone. You can too October 2011.”,
link = “http://www.mylink.com”,
caption = “Think you have what it takes to stop the monsters?”,
picture = “http://www.mylink.com/files/fbookpromo.png”,
actions = json.encode( { { name = “Learn More!”, link = “http://www.mylink.com” } } )
}
]]–
– post facebook message –
local msg = “I’m playing my game on my iPhone! You can too March 2012!”
facebook.request(“me/feed”,“POST”,{message = msg});
– onComplete function to handle all of the stuff after –
local function onComplete(event)
– Update time last posted to current date –
local date = os.date("*t");
local curr_date = date.month…"-"…date.day…"-"…date.year;
db:set(“last_shared”,curr_date);
– Update number of coins –
local curr_coins = tonumber(db:get(“goobers”));
curr_coins = curr_coins + 100;
db:update(“coins”,curr_goobers);
– log out of facebook –
facebook.logout();
end
– Create an alert to tell the person that the post has been made –
native.showAlert(“Awesome!”,“You now have +100 Coins!”,{“Close”},onComplete);
end
elseif ( “request” == event.type ) then
native.showAlert( “Error!”, event.response, { “OK” } )
end
end
facebook.login(“MY_APP_ID_HIDDEN”,listener,{“publish_stream”});
end[/lua]
[import]uid: 63800 topic_id: 22296 reply_id: 322296[/import]