Hello marc.jd. I’m a newbie too but I’ll gladly help you with everything I can. Are you sure you provided the right key hash? Please show us your code so we can help you debug it. Usually in Corona, when a faulty code is executed, it just does nothing or freezes, at least that’s my experience, in some bigger errors, the app crashes. So you might have coded it wrong. My guess is that you used some variables or functions that have not been initialized yet. It’s almost always the case for me when I do something wrong. I’m a .NET developer and understanding Corona code is not hard but I had to get used to the coding style, Corona reads from top to bottom always.
much appreciated thank u and me too i had to get used to it too and its quite good and here’s my code for the log in and the build setting.
-----build setting-------------
settings =
{
orientation =
{
default = “landscapeRight”, supported =
{
“landscapeRight”,“landscapeLeft”
},
},
android =
{
googlePlayGamesAppId = “XXXXXXXX”,
usesPermissions =
{
“android.permission.INTERNET”,
},
},
plugins =
{
[“facebook”] =
{
– required
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone = true, [“iphone-sim”] = true },
},
},
plugins =
{
– key is the name passed to Lua’s ‘require()’
[“CoronaProvider.gameNetwork.google”] =
{
--required!
publisherId = “com.coronalabs”,
supportedPlatforms = { android = true }
},
},
}
so the fcb_leaderboard is a scrollview in wich i will add scores of friends after the log in and the facebookconnect integer is to see if user logged in so it will be saved as 1 so each time the app start it will log in to Facebook automatically
------------code—
local facebook = require( “facebook” )
local json = require( “json” )
local fbCommand = nil
local appId = “XXXXX”
function changemenu3()
facebookconnect = 1
local facebookconnectFilename = “facebookconnect.data”
saveValue(facebookconnectFilename, tostring(facebookconnect) )
connect_fcb.y = 100
connect_fcb:prepare(“disconnect”)
connect_fcb:play()
fcb_leaderboard.x = 132
cb_leaderboard.y = 270
end
function facebookListener(event)
print( “Facebook Listener events:” )
–
if ( “session” == event.type ) then
– event.phase is one of: “login”, “loginFailed”, “loginCancelled”, “logout”
– statusMessage.textObject.text = event.phase – tjn Added
print( "Session Status: " … event.phase )
if event.phase == “login” then
if(facebookconnect==0)then
changemenu3()
end
end
if event.phase == “logout” then
end
if event.phase == “loginFailed” then
function cancelfcbalert(event)
if(event.action==“clicked”)then
if(event.index == 1)then
native.cancelAlert( alert )
end
end
alert = native.showAlert( “”, “Facebook login error. Check connection or try again later.”, { “Done” }, cancelfcbalert )
end
end
– The following displays a Facebook dialog box for posting to your Facebook Wall
elseif ( “request” == event.type ) then
local response = event.response
elseif ( “dialog” == event.type ) then
end
end
function connect_tofcb(event)
if(event.phase==“began” and gamestart==false)then
if(facebookconnect==0)then
facebook.login( “XXXXXXXXX”, facebookListener , { “public_profile”,“user_friends” } )
else
function areyousurefcb( event )
if(event.action==“clicked”)then
if(event.index==1)then
facebook.logout( )
facebookconnect = 0
local facebookconnectFilename = “facebookconnect.data”
saveValue(facebookconnectFilename, tostring(facebookconnect) )
connect_fcb.y = 250
connect_fcb:prepare(“connect”)
connect_fcb:play()
fcb_leaderboard.x = 132
fcb_leaderboard.y = 2000
else
native.cancelAlert( alert )
end
end
end
alert = native.showAlert( “”, “Are you sure you want to disconnect from this Facebook account?”, { “Yes”, “No” }, areyousurefcb )
end
end
end
connect_fcb:addEventListener(“touch”, connect_tofcb )
and thank you so much
Let’s do this baby steps and one at a time. I suggest you remove codes for now. Start with the very basic. Are you able to sign in to Facebook without accessing the leaderboard? I have removed the extra code I have and here’s my basic Facebook login code, this works because I am using this. If this works for you, then let’s add a little more code again until we get to your goal. I’ve always done this technique which works for me always. This will do a login and post ‘Success’ on your wall.
local facebook = require "facebook" local button1 local function listener( event ) print( "event.name", event.name ) --"fbconnect" print( "event.type:", event.type ) --type is either "session", "request", or "dialog" print( "isError: " .. tostring( event.isError ) ) print( "didComplete: " .. tostring( event.didComplete ) ) if ( "session" == event.type ) then --options are: "login", "loginFailed", "loginCancelled", or "logout" if ( "login" == event.phase ) then local access\_token = event.token facebook.request( "me/feed", "POST", { message="Success" } ) end elseif ( "request" == event.type ) then print("facebook request") if ( not event.isError ) then local response = json.decode( event.response ) --text.text= event.response end elseif ( "dialog" == event.type ) then print( "dialog", event.response ) --text.text= event.response --handle dialog results here end end local function buttonTouch(event) --take in the event and get the associated display object local myButtons = event.target --now find out which button it is local nameString = myButtons.id --use began and ended phases to change text based on touches if event.phase == "began" then --set the label text to the id elseif event.phase == "ended" then if nameString == "button0" then elseif nameString == "button1" then facebook.login( fbAppID, listener, {"publish\_actions"}) end end return true end button1 = widget.newButton{ id = "button1", label = "Login to Facebook", emboss = false, shape = "roundedRect", left = 1000, top = ((display.contentHeight/10)\*6)-20, width = controlwidth, height = controlheight, cornerRadius = 2, fillColor = { default={ 1, 0.2, 0.5, 0.7 }, over={ 1, 0.2, 0.5, 1 } }, strokeWidth = 4, onEvent = buttonTouch }
no still it also freeze and then crash because its not responding i should also mention that with my codes it works one time then after it freezes after a couple of hour and maybe a day it work again if u want i could send u the apk to see it for yourself if u want?
Sure thing, just send me the whole folder of your app, I’ll compile it myself if you don’t mind. I’ll check everything and report back to you. Remove any secret data you have before sending it to me. I’m not going to use any of your secret data but I want to play safe because I don’t want to get in any trouble. My email is chris_techno25@yahoomail.com. I have problems with Facebook myself but not like your problem, I’m done with your trouble. In fact, it’s the only thing left to do on my app. I finished my app in a week and I’ve got so much delay because of Facebook, all the trouble just to get the app to post a score. By the way, what phone do you have? I have a Nexus 5.
i have a galaxy note 3 and my app is already on play store but the next update include a global and a friends leaderboard i managed the global leaderboard the only thing delaying me is the friends one here’s a link to the one on play store https://play.google.com/store/apps/details?id=com.live.Mjay.games.FellinHell_android
and am gonna give u the link of the one am working on by drop box not email
https://www.dropbox.com/s/52kq72vvq7d73fm/FellinHell.apk?dl=0
i think corona has some bugs in facebook cause my login sometime works sometimes no…and what do u mean by posting a score like in a status? maybe i could help?
Well I can post status on Facebook fine, my problem is that the first time I login, it doesn’t do so even if it’s coded to do so. My app can post the status the second time I tap the post button. It’s weird because it should post the first time. And one more thing that annoys me, everytime I tap the post button, a black screen appears and disappears, this is the facebook login. This is after the 1st login. Should this happen all the time? And how do I post a word as status that when clicked, links to the android play store? Thank you very much. I will test your code and report back to you. Although it might not be now because it’s already midnight here. But I will post back any result I get I promise. By the way, there’s no way I can debug your code if you only send me an apk file. Please do send me your code, just remove any of your secret game code and leave the facebook stuff. Make sure it works already, so I don’t have to check everything if something does not run.
yeh ill give u the code as soon as i can(am not home right now) but tell me did it work can u log in?
and did u request permission to “publish_actions” when logging in after u have to request to post like
local postMsg = {
message = “your message”,
source = {
baseDir=system.ResourceDirectory,
filename=“imge source”,
type=""},
}
facebook.request( “me/feed”, “POST”, postMsg )
Hi Marc, actually no, when I login it doesn’t freeze, but it does nothing at all. I’m not sure what the problem of your app is, but we can solve that by reviewing your code, I’ll wait for it. Yeah, I did that code you sent me but still the same. By the way, how did you get your app to be approved by Facebook. I submitted my app for approval twice and Facebook still disapproved it because I lack information. I submitted screenshots and step by step instruction. Facebook sent me these things that I should have…The screenshot is in Dropbox. Facebook says I need to have Facebook Login. Do you have to have a separate LOGIN button and posting? Thank you very much. I’m not really having that much trouble with the Facebook Corona codes, my app just doesn’t get approved, but almost everything works fine, just that annoying black screen, but it still does the thing. Yeahp I did request ‘publish_actions’ and it works, the problem is that the first time I login it doesn’t do so, only the 2nd time. This can be solved by adding some additional codes but I was just wondering why this happens so even if I coded it to post even for the 1st time the user logs in. I’ll investigate on this further.