find which friends of user like facebook "PAGE" - facebook-graph-api

I have a Facebook page and few apps built for it, and obviously have few fans of the page.
I'd like to know which friends of the currently logged in user (who is already my fan) are also my fan, i.e. find out how many users in current user's friend list are fans of my page.
I've tried to use friends.getappusers, but its deprecated.
FQL:
SELECT uid FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ?)
AND is_app_user = 1
--again an app usage.
OLD API: $facebook->api_client->friends_getAppUsers();
GRAPH API: $facebook->api(array('method' => 'friends.getAppUsers'));
I Know an app can do this.. but that wont help, I want the page to likes to be measured and not the app likes or usage..

Related

Facebook Unity SDK - get list of friends which use the application

I'm using the Facebook Unity SDK 5.0.3 (building an Andorid player) and running into an issue trying to get a list of the friends which use the application. Have found various examples which use fql for that purpose, e.g "'/fql?q=SELECT uid, name, is_app_user, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'", but using the last in FB.API ended up with "400 Bad Request" error.
Any ideas?
10x
Well, manage to find the solution. The problem was using FQL from JavaScript documentation example as is. The following code does the work:
var fqlQuery = "/fql?q=" + WWW.EscapeURL("SELECT uid, name, is_app_user, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1");
FB.API(fqlQuery, Facebook.HttpMethod.GET, GetFbFriendsCallback);
The GetFbFriendsCallback code can be found in Smash Friends sample application provided with SDK.

Batch retrieval of friend profile photos

I have successfully retrieved up to 50 user's profiles using the batching method. I attempted to use the same process to retrieve these user's profile photos, but get an error 302. I see that there is a URL pointing to the photo returned in the result, but using that to retrieve each photo would defeat the purpose of batching, which is to retrieve all at once and prevent repeated HTTP requests. Is it possible to retrieve these using the batching in the Facebook API?
Try FQL:
SELECT pic_square FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())
...where pic_square can be one of pic_small, pic_big, pic_square, pic
That'll give you URLs for the corresponding user's profile picture at the given size.
e.g.:
https://developers.facebook.com/tools/explorer/?method=GET&path=fql%3Fq%3DSELECT%20pic_square%20FROM%20user%20WHERE%20uid%20IN%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%29

How do I list my app users in facebook

I'm trying to get all the users of my application. So far I found this method:
SELECT uid FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)
However this return my friends who are using the app. I want all users, whether they are my friends or not. Is something like this possible?
It is not possible for security reasons. You have to log your app users but there are restrictions about this issue. You can check it out from: http://developers.facebook.com/policy/

Get my UID using FQL

I need to get my UID using a simple FQL query, for some reason it returns an empty page.
This is my query:
https://api.facebook.com/method/fql.query?query=SELECT uid FROM user WHERE uid=me()
me() returns the current connected user. So you need to append an access_token:
https://api.facebook.com/method/fql.query?query=SELECT uid FROM user WHERE uid=me()&access_token=XXXXXX
P.S.: Facebook has just released a Graph API endpoint to query FQL fql, so you should be able to do something like:
https://graph.facebook.com/fql?q=SELECT uid FROM user WHERE uid=me()&access_token=XXXXXX
(unfortunately, for some reason it's not working on the Facebook Graph Explorer)

FB.api - are users unique?

So in my app, I do this:
FB.api('/me', function(response) {
alert(response.name);
});
This gives me the users name IF they are logged into FB through my site. Now, is there a way I can get a unique ID for them as well? That way everytime they post something on my site, I can store their post along with their FB name AND Id, and then I know which posts they have made in the past when they are connected to their FB through my site.
You can use response.id to get the Facebook Users unique id.