Retrieve multiple fields in a single request with Facebook PHP SDK
facebook, facebook-graph-api, facebook-php-sdk, php
Solution
Use field expansion, just one API call:
/me?fields=name,picture.width(500).height(500),birthday
API Explorer test: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Dname%2Cpicture.width%28500%29.height%28500%29&version=v2.2
More information about field expansion: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#fieldexpansion
Batch Requests would be another solution, although not a very good one in that case because they are a lot more complicated (more code, more things to consider) and they don´t count as one call:
each call within the batch is counted separately for the purposes of calculating API call limits and resource limits
...meaning, they are only faster than 2 separate calls (as fast as the slowest call in the batch), but field expansion is really just 1 call. Batch Requests are for "potentially unrelated Graph API calls".
Problem
Upon user registration I fetch the users data (name, birthday, location, etc) and also the users profile image. Currently, I would be able to do this: `/me?fields=picture,name`, but the picture returned is too low resolution, so I'd like to fetch the picture with the height parameter (as described here). My only option, as I see it, is to part it up in two requests, which seems inefficient: - Get user data `me/?fields=name` - Get user picture `me/picture?height=500&redirect=false` Would there be a way to merge this into ONE request?