Al3x
Al3x

Reputation: 125

How to get name and profile picture given multiple ids

I'm trying to optimize my queries to Facebook.

I have a list of N facebook-app-ids (N<=30), I need the name and profile picture of all of them.

Currently I do N+1 queries, one for ALL the names, and one for each profile picture.

I use this call

string query = "?ids=";

for(int i = 0; i < users.Count; i++)
{
    query+= users[i].fbId + ",";
}

query = query.Remove(query.Length - 1);

//query looks something like: "?ids=id1,id2,idN"
FB.API(query, HttpMethod.GET, ApiCallback);

What I get is something like:

{"id1":{"name":"User 1","id":"id1"},"id2":{"name":"User 2","id":"id2"},"idN":{"name":"User N","id":"idN"}}

I'd like to add the profile picture param to the query, so I'd get the name AND the picture in the JSON.

Is it even possible to do what I attempt? The idea is to avoid having to make another call for each user to get their picture, like

WWW url = new WWW(System.Uri.EscapeUriString("https://graph.facebook.com/" + idN + "/picture?type=large"));

NOTE: The pictures should be pretty small, like 100x100 or near it, so they would be pretty easily obtainable.

NOTE2: What I'm asking is what should "query" be to request via FB.API the name AND profile picture of a serie of ids

Upvotes: 0

Views: 135

Answers (1)

lars.schwarz
lars.schwarz

Reputation: 1274

Append &fields={list-of-fields} to your query

Upvotes: 2

Related Questions