Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo Plugins Support › Facebook get information

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #19961

    Nicola

    Hi,

    i don’t receive the friend lis and my email with the facebook plugin, my code:

    Facebook {
            id: facebook
            // this is the Facebook App Id received from the settings in developers.facebook.com/apps
            appId: "XXXXXXXX"
            readonly property bool loggedIn: sessionState === Facebook.SessionOpened
            // the permissions define what your app is allowed to access from the user
            readPermissions: [ "public_profile", "email", "user_friends" ]
            publishPermissions: [ "publish_actions" ]
    
            onSessionStateChanged: {
                if (sessionState === Facebook.SessionOpened) {
                    console.debug("Session opened.");
    
                    fetchUserDetails()
                    facebook.getGraphRequest("me/friends", { fields: "id,name,picture" }) // get friends that use the app
                }
                else if (sessionState === Facebook.SessionOpening) {
                    console.debug("Session opening...");
                }
                else if (sessionState === Facebook.SessionClosed) {
                    console.debug("Session closed.");
                }
                else if (sessionState === Facebook.SessionFailed) {
                    console.debug("Session failed.");
                }
                else if (sessionState === Facebook.SessionPermissionDenied) {
                    console.debug("User denied requested permissions.");
                }
            }
    
            Component.onCompleted: {
                //  facebook.openSession();
            }
            onProfileChanged: {
                 console.debug("Currently logged in user last name:", profile.lastName + " " + profile.verified
            }
            onGetGraphRequestFinished: {
              if(resultState !== Facebook.ResultOk)
                NativeDialog.confirm("Retrieving Friends Failed", "", function(){}, false)
    
              // show friends
              if(graphPath === "me/friends") {
                console.log(JSON.parse(result).data)
              }
            }
        }
    

     

    #19966

    Nicola

    In this ways it’s ok:

        Facebook {
            id: facebook
            // this is the Facebook App Id received from the settings in developers.facebook.com/apps
            appId: "XXXXX"
            readonly property bool loggedIn: sessionState === Facebook.SessionOpened
            // the permissions define what your app is allowed to access from the user
            readPermissions: [ "public_profile", "email", "user_friends" ]
            publishPermissions: [ "publish_actions" ]
    
            onSessionStateChanged: {
                if (sessionState === Facebook.SessionOpened) {
                    console.debug("Session opened.");
    
                    fetchUserDetails()
                    facebook.getGraphRequest("me", { fields: "email" }) // get friends that use the app
    
                }
                else if (sessionState === Facebook.SessionOpening) {
                    console.debug("Session opening...");
                }
                else if (sessionState === Facebook.SessionClosed) {
                    console.debug("Session closed.");
                }
                else if (sessionState === Facebook.SessionFailed) {
                    console.debug("Session failed.");
                }
                else if (sessionState === Facebook.SessionPermissionDenied) {
                    console.debug("User denied requested permissions.");
                }
            }
    
            Component.onCompleted: {
                //  facebook.openSession();
            }
            onProfileChanged: {
                 console.debug("Currently logged in user last name:", profile.lastName + " " + profile.verified)
                //facebook.getGraphRequest("me/friends", { fields: "id,name,picture" }) // get friends that use the app
    
               }
    
    
            onGetGraphRequestFinished: {
                console.log("onGetGraphRequestFinished")
              if(resultState !== Facebook.ResultOk)
                NativeDialog.confirm("Retrieving Friends Failed", "", function(){}, false)
    
              if(graphPath === "me") {
                console.log("EMAIL " + JSON.parse(result).email)
              }
            }
        }

     

    #20325

    Carlos J Yu

    I can’t seem to retrieve my facebook email with the code above.

    my resultState == 3.

    and returns son parse error maybe because the result is null.

    please help

    #20333

    Günther
    Felgo Team

    Hi Carlos,

    there can be several reasons for issues with Facebook, e.g.:

    • Wrong Facebook App Configuration: Please make sure that the Facebook App is correctly configured.
    • Some error in code / wrong graph request: Please make sure to that the api request is valid and works, e.g. with Facebook Graph API explorer.
    • Permissions: Make sure to request correct permissions

    You can check the resultState with the available Facebook Plugin enumerations:

    • Facebook.ResultOk (request successfully performed)
    • Facebook.ResultPermissionDenied (the user did not allow the requested permissions for a getGraphRequest() request)
    • Facebook.ResultError (the request ended with another error)
    • Facebook.ResultInvalidSession (the plugin needs an open session before it can call the API, make sure to call openSession() before)

    Best,
    Günther

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.