Question

Is it possible to limit the fields that are returned from Facebook's Batch request API using the JavaScript SDK? For example:

    FB.api('/', 'POST', {
        batch: [
            { method: 'GET', relative_url: 'me'},
            ...
        ]
    }, function (response) {
        console.log(response);
    });

The first method of the batch request above returns the full user graph. However, what if I only wanted to fetch a few fields (e.g. first_name and last_name). Something like this would be nice, but doesn't work:

        batch: [
            { method: 'GET', relative_url: 'me', fields: 'first_name,last_name'},
            ...
        ]
Was it helpful?

Solution

With some requests you can use the &fields= appended to the end of the url. like /me?fields=first_name,last_name

OTHER TIPS

Use FQL queries to filter out certian fields your require... eg :

SELECT uid, name, first_name, pic_square FROM user WHERE uid = me()

this query will return the user_id, full name, first name and 50x50 pixel profile picture for the user that is currently connected...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top