I would like to get a list of friends of a user. In this list I would like to know which users also have the app installed.
According to https://developers.facebook.com/docs/reference/api/user/ there is an installed parameter that can be accessed through the graph api.
I am trying to do so with the following query but I am having trouble getting the result. (I split the query on multiple lines for readabilty)
var query = "SELECT uid, name, first_name, last_name, pic_square, status, installed FROM user ";
query += "where uid IN (SELECT uid2 FROM friend WHERE uid1 = " + Titanium.Facebook.uid + ")";
query += "order by first_name";
Just had a look at this using the api explorer. You want "is_app_user" as the field for an FQL query and not installed as that doesn't exist in fql but is an api endpoint
fql?q=SELECT uid, name, first_name, last_name, pic_square, status, is_app_user FROM user where uid IN (SELECT uid2 FROM friend WHERE uid1 = me()
or try
https://developers.facebook.com/tools/explorer/433871385166/?method=GET&path=fql%3Fq%3DSELECT%20uid%2C%20name%2C%20first_name%2C%20last_name%2C%20pic_square%2C%20status%2C%20is_app_user%20FROM%20user%20where%20uid%20IN%20(SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me())
Related
This:
SELECT first_name, last_name, likes_count FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY likes_count ASC
I'm using the Graph Explorer. My access token has "friends_likes" and "user_likes" enabled.
However, that query for the active logged in user (me) works.
SELECT first_name, last_name, likes_count FROM user WHERE uid=me()
The query
SELECT first_name, last_name, likes_count FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY likes_count DESC
works perfectly fine for me. Please note that users have the possibility to deactivate the access to their data for apps their friends are using. That's why you'll see for some of your friends null as result value!
I can get events created by my friends:
SELECT eid, name, start_time, pic_cover.source, location, venue FROM event
WHERE creator IN (SELECT uid2 FROM friend WHERE uid1=me())
But I want to get my friends names asociated to that events. How can I think of that?
As FQL doesn't support joins between tables, the only solution I can think of is that you match the names of your friends and the events they created in your application.
Therefore, you'd need to issue two separate statements:
SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())
and
SELECT eid, creator, name, start_time, pic_cover.source, location, venue FROM event WHERE creator IN (SELECT uid2 FROM friend WHERE uid1=me())
and then match them via uid (from the first query) and creator (from the second query).
I'm trying to find all my friends with a specific job title, and no matter what I put in filter, it always return nothing
FQL query:
select name, work.position from user where work and uid in (select uid1 from friend where uid2 = me())
and work.position.id= 103141116410872
Hi i am new in using facebook api
i want to get the friends status based on following criteria
Get all the friends details (name, uid, status_message, posted_date) whose status update has more than 15 comments/likes
following query is giving all friends status updates
SELECT status_id, uid , message FROM status WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Above query returns all my friends updates but i want to include the comments and likes on those updates in the response so that i can check the count on my side
there are comments table and likes table also in the api both might have foreign key relationship with the status_id column
Can we write a full query with joins like SQL
You can't do JOINs in FQL, but you can approximate them with a multiquery:
{
'status': 'SELECT status_id, uid , message FROM status
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())',
'comments': 'SELECT post_id, fromid, time, text FROM comment
WHERE post_id IN (SELECT status_id from #status)'
}
I'm trying to get a list of common likes (public) between a user and his friends. I thought this FQL query would work but I'm getting an unknown user error:
--get page_id that you have and any of your friends have
https://api.facebook.com/method/fql.query?query=
select uid, page_id from page_fan where uid in (SELECT uid2 FROM friend WHERE uid1 = me()) and page_id in (select page_id from page_fan where uid= me())
&access_token=ABC
I'm getting this error:
<error_response><error_code>1</error_code><error_msg>An unknown error occurred</error_msg></error_response>
Any suggestions?
It seems that the result set is way to big for the API to handle. Your best bet is to try to limit the result set by either query a set of friends against the user's like or query one, two ...etc pages at a time (if that also didn't work try to LIMIT your friends to say 100 to make sure you are actually getting something). Example of a query:
select uid, page_id
from page_fan
where uid in (
SELECT uid2
FROM friend
WHERE uid1 = me()
) and page_id in (
select page_id
from page_fan
where uid= me()
LIMIT 1
)
Obviously there is no offset in FQL. So first, you need to retrieve the user's likes and then query against them. You can always use the batch api to make multiple calls in a single batch call.
SELECT page_id from page_fan WHERE uid = me() and page_id IN ( SELECT page_id from page_fan WHERE uid = give one hid here )