Pergunta

What would the FB.API call be to get 10 random friends? I am pretty sure this can be done with an fql query, but I do not know the exact syntax.

It would have the form:

FB.API(fqlQuery, Facebook.HttpMethod.GET, getNRandomFriendsCallback);

So my question, is what should fqlQuery be equal to?

I currently have it set to: string fqlQuery = "/fql?q={SELECT uid, name FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ) ORDER BY rand() limit 10 }";

But this returning 400 Bad Request.

Thank you.

Foi útil?

Solução

You need to url encode your fql query since it's going over the wire as a HTTPS GET param:

var fqlQuery = "/fql?q=" + WWW.EscapeURL("SELECT uid, name FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ) ORDER BY rand() limit 10");
FB.API(fqlQuery, Facebook.HttpMethod.GET, getNRandomFriendsCallback);

fqlQuery would then look like this: /fql?q=SELECT%20uid%2C%20name%20FROM%20user%20WHERE%20uid%20IN%20(%20SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me()%20)%20ORDER%20BY%20rand()%20limit%2010

You can read more about Unity's url encoded method here: http://docs.unity3d.com/Documentation/ScriptReference/WWW.EscapeURL.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top