facebook.request not call facebookListener

I’m loggin in facebook and in login response making a request to get the invitable friends…but facebookListener is not being called after facebook.request( “me/invitable_friends”)

local function facebookListener(event)

    if (event.type == “session”) then

        if (event.phase == “login”) then

            sessionToken = event.token

             facebook.request( “me/invitable_friends”) 

        elseif (event.type == “request”) then

       native.showAlert(“Facebook listener”, “request”)

           if ( not event.isError ) then

            local responseJson = json.decode( event.response )

            native.showAlert(“Me Request”, responseJson)

        else 

        native.showAlert(“erro”, “erro”)

        end

        end

    end

end

Any messages in your device’s console log?

Rob

Nothing…When I click on login…I’m getting the following warning before the popup shows…

<Warning>: FBSDKLog: Cannot use the Facebook app or Safari to authorize, fbxxxxxxx is not registered as a URL Scheme

But I have already add in config… its my confg file: 

settings = { plugins = &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; ["facebook"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["plugin.google.play.services"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; }, orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", } }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay UIApplicationExitsOnSuspend = false, -- uncomment to quit app on suspend FacebookAppID = "xxxxxxxxx", CFBundleURLTypes = { { CFBundleURLSchemes = { "fbxxxxxxx",&nbsp; } } } CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, } }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", &nbsp; &nbsp; &nbsp; &nbsp; "android.permission.ACCESS\_NETWORK\_STATE", }, }, }

And when I alert the token after login…I’m getting the session token properly…but if I make a request now I’m getting 

“<Warning>: FBSDKLog: Error for request to endpoint ‘me/invitable_friend’: An open FBSession must be specified for calls to this endpoint.”

I see at least one error. You’re missing a comma after the outer brace in this block:

CFBundleURLTypes = { { CFBundleURLSchemes = { "fbxxxxxxx",&nbsp; } } }, --\<------- needs a comma here

Secondly, I can’t tell if you’re replacing the xxxxxxxx’s with your AppID or not. You can’t use the xxxx’s there, it has to be your Facebook AppID.  Still the likely error is the missing comman

Rob

Yes, I’m using the FB APP id instead of xxxxx…

Now, I put the comma but the error still the same…

Nov 29 11:56:23 iPhone Whois[12703] <Warning>: FBSDKLog: Cannot use the Facebook app or Safari to authorize, fb1467526290126123 is not registered as a URL Scheme

There’s my updated settings (with a not real id)

-- -- For more information on build.settings see the Corona SDK Build Guide at: -- http://docs.coronalabs.com/guide/distribution/buildSettings/index.html -- settings = { plugins = &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; ["facebook"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["plugin.google.play.services"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; }, orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", } }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay UIApplicationExitsOnSuspend = false, -- uncomment to quit app on suspend FacebookAppID = "1467526290126123", --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1467526290126123", &nbsp;-- replace XXXXXXXXX with your Facebook appId } } }, --]] CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, } }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", &nbsp; &nbsp; &nbsp; &nbsp; "android.permission.ACCESS\_NETWORK\_STATE", }, }, }

It would be really useful if your build.settings was properly indented. It’s really hard to see where one {  begins and which one closes it.

any way, if I read this right, you have the CFBundleURLTypes table commented out. See the --[[before it and --]] after it?

Rob

Great! This error was because the URLSchemes was commented haha :frowning:

But now I’m receiving the following error “This app is not allowed to query for scheme fb”

Then I still not receiving the callback 

We are progressing! I add the following lines in build.settings: 

 NSAppTransportSecurity = { NSAllowsArbitraryLoads = true }, LSApplicationQueriesSchemes = { "fbauth" },

Now the message error “This app is not allowed to query for scheme…” disappeared…I receive login callback but when I try to make a request

&nbsp; &nbsp; &nbsp;facebook.request( "me/invitable\_friends")&nbsp;

I’m getting

<Warning>: FBSDKLog: Error for request to endpoint ‘me/invitable_friend’: An open FBSession must be specified for calls to this endpoint.

Next sanity check, the me/invitable_friends Graph API endpoint is only available to Facebook Apps targeting Graph API v2.0 or later.

In the dashboard for your Facebook app (on developers.facebook.com), verify that the API version is at least v2.0.

Api Version: v2.0

I have no more idea for show the player’s friend …

How could I specify an session? The request is already in login return…then I have already the session token…why its not recognized in my request? Should I pass as parameter? 

I’ve tried: 

local function facebookListener(event)

    if (event.type == “session”) then

        if (event.phase == “login”) then

        token = event.token

        print("token "…token)

       

 facebook.request( “me/invitable_friend?access_token=”…token)

        elseif (event.type == “request”) then

       native.showAlert(“Facebook listener”, “request”)

           if ( not event.isError ) then  

              native.showAlert(“req”, event.type)

         –    – local response = event.response

        print("response "…event.response )

        else 

        native.showAlert(“erro”, “erro”)

        end

        end

    end

end

I got the token in console log but when I make the request:  facebook.request( “me/invitable_friend?access_token=”…token)

I get the following error: 

<Warning>: FBSDKLog: Error for request to endpoint ‘me/invitable_friend?access_token=ACCESS_TOKEN_REMOVED’: An open FBSession must be 

Any messages in your device’s console log?

Rob

Nothing…When I click on login…I’m getting the following warning before the popup shows…

<Warning>: FBSDKLog: Cannot use the Facebook app or Safari to authorize, fbxxxxxxx is not registered as a URL Scheme

But I have already add in config… its my confg file: 

settings = { plugins = &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; ["facebook"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["plugin.google.play.services"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; }, orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", } }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay UIApplicationExitsOnSuspend = false, -- uncomment to quit app on suspend FacebookAppID = "xxxxxxxxx", CFBundleURLTypes = { { CFBundleURLSchemes = { "fbxxxxxxx",&nbsp; } } } CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, } }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", &nbsp; &nbsp; &nbsp; &nbsp; "android.permission.ACCESS\_NETWORK\_STATE", }, }, }

And when I alert the token after login…I’m getting the session token properly…but if I make a request now I’m getting 

“<Warning>: FBSDKLog: Error for request to endpoint ‘me/invitable_friend’: An open FBSession must be specified for calls to this endpoint.”

I see at least one error. You’re missing a comma after the outer brace in this block:

CFBundleURLTypes = { { CFBundleURLSchemes = { "fbxxxxxxx",&nbsp; } } }, --\<------- needs a comma here

Secondly, I can’t tell if you’re replacing the xxxxxxxx’s with your AppID or not. You can’t use the xxxx’s there, it has to be your Facebook AppID.  Still the likely error is the missing comman

Rob

Yes, I’m using the FB APP id instead of xxxxx…

Now, I put the comma but the error still the same…

Nov 29 11:56:23 iPhone Whois[12703] <Warning>: FBSDKLog: Cannot use the Facebook app or Safari to authorize, fb1467526290126123 is not registered as a URL Scheme

There’s my updated settings (with a not real id)

-- -- For more information on build.settings see the Corona SDK Build Guide at: -- http://docs.coronalabs.com/guide/distribution/buildSettings/index.html -- settings = { plugins = &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; ["facebook"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["plugin.google.play.services"] = &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisherId = "com.coronalabs" &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; }, orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", } }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay UIApplicationExitsOnSuspend = false, -- uncomment to quit app on suspend FacebookAppID = "1467526290126123", --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1467526290126123", &nbsp;-- replace XXXXXXXXX with your Facebook appId } } }, --]] CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, } }, -- -- Android Section -- android = { usesPermissions = { "android.permission.INTERNET", &nbsp; &nbsp; &nbsp; &nbsp; "android.permission.ACCESS\_NETWORK\_STATE", }, }, }

It would be really useful if your build.settings was properly indented. It’s really hard to see where one {  begins and which one closes it.

any way, if I read this right, you have the CFBundleURLTypes table commented out. See the --[[before it and --]] after it?

Rob

Great! This error was because the URLSchemes was commented haha :frowning:

But now I’m receiving the following error “This app is not allowed to query for scheme fb”

Then I still not receiving the callback