Facebook Login Problem

I am using the latest daily build (2012.769) and i was working on adding facebook to my app to be able to publish a score to the users wall. the code i am using is:

[lua]–Facebook function
local faceListener = function (event)
if event.type == “session” then
if event.phase == “login” then
facebook.request( “me/feed”, “POST”, {message = “Hello Facebook”} )
end
end
end

local faceFunc = function ()
facebook.login(“myappID”, faceListener, {“publish_stream”} )
end[/lua]

i was using this code just to get the initial test and when ever i hit the button to run the function facebook comes up and just displays loading and the loading circle, nothing else happens, so i uninstalled all updates to the facebook app that came with my phone and at that point i can log in but after i log in the page is white and does not change. This app is for android only right now and i have the android hash setup and the facebook dev account setup. Any advice on what could be causing these errors? [import]uid: 126161 topic_id: 23635 reply_id: 323635[/import]

Have you updated your build.settings to work with the Facebook API? After Corona added the Single Sign On feature as of Daily Build 707, if you require Facebook API, you will also need to add CFBundleURLSchemes to your build.settings. If you haven’t done it yet, please see the blog post instruction carefully, and it might just solve your problem:

http://blog.anscamobile.com/2011/12/uploading-photos-to-facebook-in-corona/

Naomi [import]uid: 67217 topic_id: 23635 reply_id: 95220[/import]

The app that I am using Facebook for is android only and unless I am mistaken, i do not need to do anything to build.settings for android Facebook api. Also I am using android in app purchase so i do not want to go back to the latest stable build. If this ie a problem with daily builds then I might just leave Facebook out until it is resolved. [import]uid: 126161 topic_id: 23635 reply_id: 95245[/import]

Ah, okay. I haven’t worked on Android version yet, so I have no clue. I misinterpreted your post, thinking you already have Android version working but now porting to iOS. Hopefully, someone knowledgeable with Android & Facebook will jump in and help you out. (And I will need the very same help as soon as I get my iOS version out the door.)

Good luck!

Naomi [import]uid: 67217 topic_id: 23635 reply_id: 95250[/import]

Same issue here…did you find a fix yet?

Edit - Stable build will resolve the issue for posting as of now…did for me…
[import]uid: 101355 topic_id: 23635 reply_id: 95168[/import]

Is there any update on the facebook login problem for android? Ive noticed that i am not the only one having this issue [import]uid: 126161 topic_id: 23635 reply_id: 97690[/import]

A quick note about helper module from BobDickinson: http://developer.anscamobile.com/code/facebook-helpersupport-module

It looks thorough and gracefully done. It might be worth the trouble to look.

Cheers,
Naomi [import]uid: 67217 topic_id: 23635 reply_id: 99358[/import]

@3 Dreams Gaming, did you figure out the solution to this? I’m in the process of porting my iOS game to Android (and I’m using Kindle & Nook as the test device).

Without changing the iOS code (and even before I added the Android Key Hash), I could launch Facebook Sign In screen (just like how it works on my iOS device), and I am able to sign in and post to Facebook wall. However, unlike iOS version, when I fail to sign in (i.e., closing the sign in screen before completing it, for example), it doesn’t seem to return any feedback that the sign in failed. I’m wondering, maybe, what I need is the Android Key Hash to get this actually working properly – so I added it. But nothing changed after I generated new builds and installed the game on both Kindle and Nook. Maybe the reason why nothing changed is because it takes time before the Key Hash propagates throughout Facebook servers. (I hope that’s the only reason why it’s not working properly right now.)

Edit: I’m also using my own keystore (not the debug keystore) for my builds - if it makes any difference.

FYI, I’m using Daily Build 776 (on Mac).

Posted below is the code structure I’m currently using (in case it helps).

Anyhow, it would be great to hear how things went with you.

Naomi

Edit: I added the login error trap that was missing from the code structure below. By looking at Bob Dickinson’s helper module, I noticed what was missing. The very helpful helper module is found here: https://developer.anscamobile.com/code/facebook-helpersupport-module

Edit again: I needed to edit my code below to work on Android. In my case, the further edited code works perfectly on Android device (Kindle). However, it isn’t working properly on iOS device – but it may have something to do with the fact I haven’t released iOS version, and therefore, native iOS setting isn’t properly setup on Facebook dev page.

[lua]local facebook = require “facebook”
local MyAppID = “1234567890000” – this is fake, please use valid ID.

– this one works the way I want on my Kindle
local function myFBListener()
if ( “session” == event.type ) then
if event.phase ~= “login” then
– call a function to notify the user that log in failed
return
end
– This code posts an image and a message to the user’s Facebook Wall
local attachment = {
name = “My Game”,
link = “http://www.mygame.com”,
message = “Hello hello hello.”,
picture = “http://www.mygame.com/myImage.png”,
actions = json.encode( { name = “Learn More”, link = “http://www.mygame.com” } )
}
facebook.request( “me/feed”, “POST”, attachment )
– I decided to use “me/feed” instead of “me/photos” because I don’t want the image to be saved in the user’s Facebook album
elseif ( “request” == event.type ) then
if ( not event.isError ) then
– this block is executed upon successful facebook.request() call
– call a function to notify that the user has successfully posted on Facebook wall
else
– this block is executed when posting failed
– call a function to notify that posting to Facebook failed
end
end
end
facebook.login( MyAppID, myFBListener, {“publish_stream”} )[/lua] [import]uid: 67217 topic_id: 23635 reply_id: 99268[/import]

Well i decided to hold off on facebook integration till i signed my android app with my own keystore. Yesterday i did the keystore signing and everything went fine but when i tried to get the hash for facebook, it gave me a hash and i had the same problem i have been having. So i did a logcat and it seems that i have been getting the wrong hash this whole time from the keytool. So i used the hash that the logcat gave me and it worked fine. So the problem is with the keystore hash. Im not sure if something is happening when the apk is built or what but something is happening to give a different hash when installed.
here is the command line im using to get the hash.
[lua] keytool -exportcert -alias aliasname -keystore “C:\mykeystore.keystore” | “C:\OpenSSL\bin\openssl” sha1 -binary |“C:\OpenSSL\bin\openssl” base64[/lua]
As i said before, the keystore gave me one hash and the logcat error gave me a different hash and when i used the hash that was in the logcat then it works. [import]uid: 126161 topic_id: 23635 reply_id: 101108[/import]

@3 Dreams Gaming, I thought about this hash mismatch between what you made for FB Dev site and what appears on logcat, and I wondered if you built your app using debug keystore or your own keystore. If, for some reason, your app was built using debug keystore, I’d imagine the hash won’t match… That’s the only possibility that I can think of.

Anyhow, I hope you’ll get this sorted.

Naomi [import]uid: 67217 topic_id: 23635 reply_id: 101294[/import]

Naomi, nope i used my own i made sure of it, also i did do the debug keystore again and the debug gave me a different hash than logcat did so i dont know whats going on. the command line code i used is posted above for reference. [import]uid: 126161 topic_id: 23635 reply_id: 101403[/import]

@3 Dreams Gaming, I have no idea why it isn’t working for you at this point. FYI, I used the command line that I found on Facebook Dev site when I generated the hash – what you posted might be exactly the same one, but I thought I’d mention how I got mine made.

Let’s hope someone knowledgeable will jump in and help you out with this.

Naomi [import]uid: 67217 topic_id: 23635 reply_id: 101425[/import]

Well like i said, its working now because i used the hash that logcat said my app was generating and put that in facebook and it works so its working, just had to go a round about way to get it to work. [import]uid: 126161 topic_id: 23635 reply_id: 101431[/import]

Got it. Yeah, how odd you have to do this in such a round about way, though.

Anyhow, if it works, it’s all good.

Cheers,
Naomi [import]uid: 67217 topic_id: 23635 reply_id: 101433[/import]