Problem with Facebook example code

Using the latest daily build, I’m trying to implement the example Facebook code below:

[code]
local function facebooklistener(event)
if ( “session” == event.type ) then
– upon successful login, request list of friends of the signed in user
if ( “login” == event.phase ) then
facebook.request( “me/friends” )

– Fetch access token for use in Facebook’s API
local access_token = event.token
print( access_token )
end
elseif ( “request” == event.type ) then
– event.response is a JSON object from the FB server
local response = event.response

– if request succeeds, create a scrolling list of friend names
if ( not event.isError ) then
response = json.decode( event.response )

local data = response.data
for i=1,#data do
local name = data[i].name
print( name )
end
end
elseif ( “dialog” == event.type ) then
print( “dialog”, event.response )
end
end

local function buttonpressed(event)
facebook.login("",facebooklistener,{“publish_stream”})
return true
end
[/code]

The error I get is the mysterious (at least to me) FBConditionalLog: handleOpenURL should not be called once a session has been closed.

Any ideas what’s up?

Thanks in advance,

Jon [import]uid: 127193 topic_id: 36410 reply_id: 336410[/import]

Are you getting logged in correctly? Do you have all the bits in build.settings that you need? There has been a new key added:

FacebookAppID = "yourappidnumber",  

as part of the plist block. Do you have that? What about this block of code (also in plist)

 CFBundleURLTypes = {  
 {  
 CFBundleURLSchemes = {  
 "fbyourappidnumber",  
 },  
 },  
 },  

The first one does not have the letters “fb”, the second one does.
[import]uid: 199310 topic_id: 36410 reply_id: 144609[/import]

Thanks for getting back to me Rob.

The app shifts focus to the Facebook app on my iPhone requests access then throws the error (I think it’s the facebook.request statement).

build.settings looks like this …

[code]
settings = {

orientation = {
default = “portrait”,
supported =
{
“portrait”
},
},

iphone = {
plist = {
UIStatusBarHidden = false,
UIApplicationExitsOnSuspend = true,
FacebookAppID = “”,
CFBundleIdentifier = “”,
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png”,
“Icon@2x.png”,
“Icon-72.png”,
},
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb”,
}
}
}
}
},

androidPermissions = {
“android.permission.INTERNET”,
},
}
[/code]

Anyone with ideas on what could be causing the error?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144649[/import]

UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work  

This line in build.settings solves the issue. Was pure luck I spotted it while looking at the demo Facebook code. Worth a comment somewhere in the documentation?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144665[/import]

You should also be aware that if you attempt to call facebook via url that you will need to remove the “fb” in front of the id as facebook will fail. :slight_smile: [import]uid: 174725 topic_id: 36410 reply_id: 144667[/import]

Are you getting logged in correctly? Do you have all the bits in build.settings that you need? There has been a new key added:

FacebookAppID = "yourappidnumber",  

as part of the plist block. Do you have that? What about this block of code (also in plist)

 CFBundleURLTypes = {  
 {  
 CFBundleURLSchemes = {  
 "fbyourappidnumber",  
 },  
 },  
 },  

The first one does not have the letters “fb”, the second one does.
[import]uid: 199310 topic_id: 36410 reply_id: 144609[/import]

Thanks for getting back to me Rob.

The app shifts focus to the Facebook app on my iPhone requests access then throws the error (I think it’s the facebook.request statement).

build.settings looks like this …

[code]
settings = {

orientation = {
default = “portrait”,
supported =
{
“portrait”
},
},

iphone = {
plist = {
UIStatusBarHidden = false,
UIApplicationExitsOnSuspend = true,
FacebookAppID = “”,
CFBundleIdentifier = “”,
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png”,
“Icon@2x.png”,
“Icon-72.png”,
},
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb”,
}
}
}
}
},

androidPermissions = {
“android.permission.INTERNET”,
},
}
[/code]

Anyone with ideas on what could be causing the error?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144649[/import]

UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work  

This line in build.settings solves the issue. Was pure luck I spotted it while looking at the demo Facebook code. Worth a comment somewhere in the documentation?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144665[/import]

You should also be aware that if you attempt to call facebook via url that you will need to remove the “fb” in front of the id as facebook will fail. :slight_smile: [import]uid: 174725 topic_id: 36410 reply_id: 144667[/import]

Are you getting logged in correctly? Do you have all the bits in build.settings that you need? There has been a new key added:

FacebookAppID = "yourappidnumber",  

as part of the plist block. Do you have that? What about this block of code (also in plist)

 CFBundleURLTypes = {  
 {  
 CFBundleURLSchemes = {  
 "fbyourappidnumber",  
 },  
 },  
 },  

The first one does not have the letters “fb”, the second one does.
[import]uid: 199310 topic_id: 36410 reply_id: 144609[/import]

Thanks for getting back to me Rob.

The app shifts focus to the Facebook app on my iPhone requests access then throws the error (I think it’s the facebook.request statement).

build.settings looks like this …

[code]
settings = {

orientation = {
default = “portrait”,
supported =
{
“portrait”
},
},

iphone = {
plist = {
UIStatusBarHidden = false,
UIApplicationExitsOnSuspend = true,
FacebookAppID = “”,
CFBundleIdentifier = “”,
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png”,
“Icon@2x.png”,
“Icon-72.png”,
},
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb”,
}
}
}
}
},

androidPermissions = {
“android.permission.INTERNET”,
},
}
[/code]

Anyone with ideas on what could be causing the error?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144649[/import]

UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work  

This line in build.settings solves the issue. Was pure luck I spotted it while looking at the demo Facebook code. Worth a comment somewhere in the documentation?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144665[/import]

You should also be aware that if you attempt to call facebook via url that you will need to remove the “fb” in front of the id as facebook will fail. :slight_smile: [import]uid: 174725 topic_id: 36410 reply_id: 144667[/import]

Are you getting logged in correctly? Do you have all the bits in build.settings that you need? There has been a new key added:

FacebookAppID = "yourappidnumber",  

as part of the plist block. Do you have that? What about this block of code (also in plist)

 CFBundleURLTypes = {  
 {  
 CFBundleURLSchemes = {  
 "fbyourappidnumber",  
 },  
 },  
 },  

The first one does not have the letters “fb”, the second one does.
[import]uid: 199310 topic_id: 36410 reply_id: 144609[/import]

Thanks for getting back to me Rob.

The app shifts focus to the Facebook app on my iPhone requests access then throws the error (I think it’s the facebook.request statement).

build.settings looks like this …

[code]
settings = {

orientation = {
default = “portrait”,
supported =
{
“portrait”
},
},

iphone = {
plist = {
UIStatusBarHidden = false,
UIApplicationExitsOnSuspend = true,
FacebookAppID = “”,
CFBundleIdentifier = “”,
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png”,
“Icon@2x.png”,
“Icon-72.png”,
},
CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb”,
}
}
}
}
},

androidPermissions = {
“android.permission.INTERNET”,
},
}
[/code]

Anyone with ideas on what could be causing the error?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144649[/import]

UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work  

This line in build.settings solves the issue. Was pure luck I spotted it while looking at the demo Facebook code. Worth a comment somewhere in the documentation?

Jon [import]uid: 127193 topic_id: 36410 reply_id: 144665[/import]

You should also be aware that if you attempt to call facebook via url that you will need to remove the “fb” in front of the id as facebook will fail. :slight_smile: [import]uid: 174725 topic_id: 36410 reply_id: 144667[/import]