Making multiple fb.api calls

I'm just starting to use the Facebook API.

How can I call multiple attributes with just one call to FB.api? Right now i have

        FB.api('/me', function(me){
          if (me) {
            var myEmail = me.email;
            var myID = me.id;
            var myFirst_name = me.first_name;
            //Other attributes
          }
        });

and

        FB.api('/me/friends',{ fields: 'name,id' }, function(response){
            var friends = response.data;
        }
       });

How to combine both api calls into one, for example, say only 1 FB.api()call?

All answers really help.

+5
source share
1 answer

How to combine both api calls into one, for example, only 1 FB.api () call?

You could combine them into one Batch Request - but it will help to respond a little to the answer, and I'm not sure that in any case it will bring any "performance" benefits in such a simple use case.

EDIT:

¹, :

/me?fields=id,email,first_name,friends.fields(id,name)

- id, email first_name , . (, ,friends , , , API, , ,friends.fields(…).)


¹ , , , Id .

+7

All Articles