Facebook issue

I’m hoping Peach can possibly help with this, but anyone who has any input on the manner would be much appreciated.

I have tried the Facebook example app from the SDK as well as various other examples but every time I implement the code into mine it fails to post a photo on the wall of a facebook (mine for testing) page.

Soon as I call the function for to start the process facebook.login() I see what appears to be a window expanding into place (I assume the facebook login dialog) but then it instantly vanishes and nothing happens. If I exit the app and check browser there is nothing open like it was trying to login or anything.

What I do know for sure is, the appId is good, it works in the example code standalone and makes posts. I know that the listener function is NEVER getting called and I know for sure there are no spelling typo’s or case sensitive typo’s anywhere (like specifying the listener function name). Basically I get the sense that my app isn’t letting the facebook login prompt ‘come to the top’. Like it is buried or something and so the ‘session’ never is established.

I was just hoping maybe someone could lend some info on what would cause the FB login dialog to not surface. I should state that I’m not already logged into facebook when this happens btw, so it should prompt. And once again, the listener is NEVER being called. I do know that the initiating function for the facebook.login() is happening though for sure.

The login line is like so:

facebook.login( appId, listener, {"publish\_stream"} )  

Thanks [import]uid: 78015 topic_id: 16353 reply_id: 316353[/import]

[lua]local function printTable( t, label, level )
if label then print( label ) end
level = level or 1
if t then
for k,v in pairs( t ) do
local prefix = “”
for i=1,level do
prefix = prefix … “\t”
end

print( prefix … “[” … tostring(k) … "] = " … tostring(v) )
if type( v ) == “table” then
print( prefix … “{” )
printTable( v, nil, level + 1 )
print( prefix … “}” )
end
end
end
end


local callFacebook = function()
local facebookListener = function( event )
if ( “session” == event.type ) then
– event.phase is one of: “login”, “loginFailed”, “loginCancelled”, “logout”
if ( “login” == event.phase ) then

local theMessage = “This is the text that appears as though it were a status typed in by the user”

facebook.request( “me/feed”, “POST”, {
message=theMessage,
name=“Corona and Twinkies”,
caption=“Corona is awesome. So are Twinkies. Yeah.”,
link=“http://anscamobile.com/”,
picture=“http://mysite.com/myimage.png” } )

end
end
end

facebook.login( “123456XXXXXXX”, facebookListener, { “publish_stream” } )
end[/lua]

Just make sure you have also required facebook as well as json and tableview (you can copy those from the FB sample in the CoronaSDK folder.)

Change the ID to your own.

Then add a button for callFacebook()

Let me know how that goes for you.

Peach :slight_smile: [import]uid: 52491 topic_id: 16353 reply_id: 60944[/import]

Does the exact same thing. I’m using 2011.623 of the SDK. I searched all the release notes checking to see if any FB stuff had been fixed or changed but saw nothing.

I’m resetting the test device now and reinstalling the app to see if that changes anything. [import]uid: 78015 topic_id: 16353 reply_id: 60956[/import]

I actually just tested both the sample code version (with my own ID) and the code I posted above and both actually work perfectly.

The only time I can make them close immediately is when I turn on airplane mode. (As in, network and wifi access are both off.)

Maybe that is worth looking at?

If not, test with a stable version - but that’s all I’ve come up with I’m afraid.

Peach [import]uid: 52491 topic_id: 16353 reply_id: 60965[/import]

Ya I checked that earlier too and made sure I could browse the web. It’s strange. I’m sure I could take your code and it would work stand alone fine , it just seems to be when it’s in the app it fails. It’s like something is suppressing it. But I have no global’s or anything named the same or anything else I can think of or find that would interfere with it. Thought maybe you or someone might know of some element that possibly might interfere.

Thanks for your help :slight_smile: [import]uid: 78015 topic_id: 16353 reply_id: 60969[/import]

Really it is just going to be a matter of trial and error - it works fine on its own, it works fine in the sample app and it works fine in an app I build last week that is more than just a sample.

Basically you just need to go over the rest of your code very carefully and if you can’t crack it give premium support a go. (They can do debugging.) http://www.anscamobile.com/corona/support/

Peach :slight_smile: [import]uid: 52491 topic_id: 16353 reply_id: 60975[/import]

Paul…your declaration order is faulty in the example above…you declare “postFacebook” AFTER you reference it in the alert code. That won’t work because it is still nil at the time it is first seen…forward declare it for a valid test. [import]uid: 6175 topic_id: 16353 reply_id: 61413[/import]

Ok I finally found the issue. I’m posting it in case anyone else runs into this because it cost me some time tracking it down and maybe it will help someone else.

If the following is already a known issue then sorry but I didn’t find anything about it anywhere when I was looking.

The problem is this, if you use native.showAlert() to verify the user really does want to post to FB right before you call it, it will hose you over and kill the FB login dialog box that pops up.

As an example, using the following code to call peach’s code above.

local function postFacebook(event)   
 if "clicked" == event.action then  
 local i = event.index  
 if i == 1 then  
 -- They said NO  
 audio.play(saidNoAudio)   
 elseif i == 2 then  
 -- They said YES  
 callFacebook()  
 audio.play(saidYesAudio)   
 end  
 end  
end  
  
local function askToPostFB()  
  
 local title = "Post to Facebook Page?"  
 local desc = "Do you want to post to your Facebook Page?"  
 postFacebookAnswer = native.showAlert(title,desc, {"No","Yes"},postFacebook)  
  
end  

So ummm ya, don’t do that :slight_smile:

Just do it! or, make your own confirmation prompt. [import]uid: 78015 topic_id: 16353 reply_id: 61021[/import]

This is just a section of clipped out code that was actually tried and verified and it’s not all there, so yes, in this example that would be a problem, I’ll flip it around. I was just trying to point out that showAlert will in fact cause a problem.

Thanks. [import]uid: 78015 topic_id: 16353 reply_id: 61419[/import]