tussh13
tussh13

Reputation: 87

firebase + facebook Open Graph

(I am creating a new question cause it will be easy for others to find it)

have got the login to work with firebase. trying to get access to the open graph data on the client side itself.

I have the user access Token thanks to the firebase sdk. Now I have permission to get access to the user likes.

(I have never used FB open graph before and all the examples are done using the FBphp sdk)

            var myDataRef = new Firebase('my firebase');
            var temp;           
            var authClient = new FirebaseAuthClient(myDataRef, function(error, user) {
                if (error) {
                    // an error occurred while attempting login
                    console.log('an error occurred:');
                    console.log(error);
                } else if (user) {
                    // user authenticated with Firebase
                    console.log('logged in:');
                    console.log(user.accessToken);
                    temp=user.accessToken;

    /*look here*/   $.getJSON('https://graph.facebook.com/'+ user.id +'/likes?access_token='+temp+'', function(data) {
                    console.log("Data Loaded: " + data);

                 } else {
                       // user is logged out
                       console.log('logged out');
                 }
            });

The request is successful but the data returned is not being displayed, all I am getting is [Object object] in console. Any help will be appreciated

Upvotes: 3

Views: 1615

Answers (2)

kenny
kenny

Reputation: 19

you are using json, just use console.log("Data Loaded: " + JSON.stringify(data));

Upvotes: 1

mimming
mimming

Reputation: 13954

It looks like you actually are getting some useful data back, but console.log("Data Loaded: " + data); is converting that data to the string [Object object]

To see the contents of your data, try logging with this instead: console.log(data) or use a breakpoint in your developer tools to inspect it during runtime.

Upvotes: 2

Related Questions