Facebook FQL not working under application - facebook

I have a FQL(Facebook) query running to get all the movies list from my friends.
Query :
"SELECT uid,name,movies FROM user where uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"
I have tested the application under Graph API Explorer ,its working but when i shift query to my application it doesn't work.
I have Enabled the permissions also , namely user_about_me, friends_about_me, friends_likes, user_likes , user_interests ,friends_interests.
Added Extended Permission : read_stream , read_requests.
Can anybody help in this !!

Related

How can I get only the users (friends) who are using my app?

I have a PhoneGap app, where I need to list all the user's friends, who have authorized the application on Facebook.
I'm currently using FB.api('/me/friends?fields=installed', callbackFnc), but this shows me all friends, pointing which of them have authorized the app. When I really wanted to list only the authorized ones.
This slows a lot the process of loading friends.
I saw other similar questions here, but none of them had the answer.
SOLUTION: Thanks to CBroe
I couldn't have sucess passing the FQL directly to FB.api, but only using that object:
var apiQuery =
{
method: 'fql.query',
query: 'SELECT uid, name FROM user WHERE uid IN (SELECT uid1 FROM friend WHERE uid2 = me() ) AND is_app_user'
}
FB.api(apiQuery, function(response){...});
Use FQL instead:
SELECT uid, name FROM user WHERE uid IN
(SELECT uid1 FROM friend WHERE uid2 = me() ) AND is_app_user
(You can set up that query against the Graph API as well, /fql?q={query}.)

Get relationship (friend, friend of friend) between two Facebook ids by facebook api

How can I check for the relation between two facebook ids.? i.e friend, friend of friend or there is no relation. By fql or graph api methods(anything).
I know how to get the friend list, mutual friends of facebook id. But I want a proper method which can give the relation between two Facebook ids. I have Googled a lot but didn't get anything related to my problem.
SELECT uid2 FROM friend WHERE uid1 = me() AND uid2 = {YOUR_FRIEND2_ID}
With this FQL query you can check if give ID is a friend of currently logged in user. It'll return an empty array if given users are not friends. Facebook does not give you friends of a friend, so you can't go beyond the logged in user.
To read the friend table you need
any valid access_token to retrieve friends of the current session user
This is the only user that this table can be queried for, the friends of friends cannot be retrieved.
Facebook offical documentation on friend FQL table
I got solution by checking with fql queries.
//$target_id=id of user to check relationship
//$source_id=logged in user
$query="SELECT uid, name, work FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $target_id AND uid2=$source_id)
ORDER BY name";
$user_info=$this->facebook->api(array('method'=>'fql.query',
'query'=>$query));
if(!empty($user_info))
{
$degree='friend';
}
else {
$query="SELECT uid, name, work FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM friend WHERE uid1 = $target_id) AND uid2=$source_id)
ORDER BY name";
$user_info=$this->facebook->api(array('method'=>'fql.query',
'query'=>$query));
// we can check friend-of-friend for app user friends
if(!empty($user_info)) {
$degree='friend-of-friend';
}
else{
$degree='none';
}
}
Please answer if anyone knows any simple method.

get list of facebook users who are using specific application using FQL

I am trying to fetch following case using FQL
If few users have authorized "Application A" then is it possible to know that currently how many users are using that "Application A" ( users those are not friends of each other)
So far i tried following FQL , but following query gives only information of those users who are
friends of each other and using the same application , but what about other users who are not friends ?
SELECT uid, name, pic_square
FROM user
WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
You can't get a listing of your application's users from the API. If you need this, you should maintain your own database of users and reference that.
You can also check if any particular user is a user of your application by requesting /USER_ID/permissions?fields=installed with your application access token.
You can also check if a user's friends are users of your application by requesting the same field on the friends connection (for example, /USER_ID/friends?fields=installed). In this case, the USER_ID must be a user of your application or you won't be able to access their friends list.
is_app_user on the user table when requesting friends returns this data.
SELECT uid,is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
or...
SELECT uid,is_app_user FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Which is a bit tighter - only returning those users in-app.
You can't get total number of users who have installed application, but you can get daily, weekly and monthly users with simple query:
SELECT daily_active_users, weekly_active_users, monthly_active_users
FROM application WHERE app_id = APPLICATION_ID
Note: this will work for any application (not just applications user connected to)
SELECT uid FROM user WHERE uid IN ( SELECT uid2 FROM friend
WHERE uid1 = '549483876' ) AND is_app_user = 1

Can't lookup all friends of xxxxxxxxx. Can only lookup for the logged in user (xxxxxxxxx)

I have a facebook application from where I get the friends list of the connected user's friends.
It works because i get only the friends list of my friends who have authorized my application
Here are the queries :
"app_friends":"SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1"
"potential_people":"SELECT uid2 FROM friend WHERE uid1 IN (SELECT uid FROM #app_friends)"
It worked fine until today, when I have realized that some of my friends don't authorize me to see their friends. When i m going to see their profile page, i can't see his friends.
So i get the following FQL error : Can't lookup all friends of xxxxxxxxx. Can only lookup for the logged in user (xxxxxxxxx), or friends of the logged in user with the appropriate permission
How can I specify that I want to see the list of the friends of my friends who have authorized my application AND AUTHORIZE ME TO SEE THEIR FRIENDS.
For example I have thougth about something like this :
"app_friends":"SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1 AND can_access_friends = 1"
What do you think ?

facebook friends status

i am using this fql query but not getting status its showing null in status for getting facebook friends message please help
SELECT uid, pic_square, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = 100000660426865)
The query you have built attempts to access your local host SQL server.
Would you like to get status from Facebook directly?
If so, you API provided by Facebook instead.