I have this query:
SELECT uid, name, current_location FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ) AND current_location.id IN (Select current_location.id from user where uid = me() )
It gives me results as required i-e friends only with a particular location.
Can i get the same results using Graph API instead? assuming I have the location id.
I tried this in graph API:
me/friends?location.id='111501225536407'&fields=location
Is something of ^ sort even possible using graph API?
Not that I can see. The Graph API is best for getting all of or the most recent items of an object. If you wanted to filter those friends by location, you would need to do that on the client side.
If you want Facebook to pre-filter your results on their servers, you need to use FQL.
you can execute fql queries (including multiqueries) through the graph api like this:
https://graph.facebook.com/fql?q={"albums":"select aid, name,cover_pid FROM album where owner=me()","album_covers":"select src from photo where pid in (select cover_pid from %23albums)"}&access_token=xxxxxx
It's a little tricky with the url encoding. Be sure that "#" sign used in multiqueries is encoded as %23
Related
I currently use the following FQL to search users with name containing "Peter":
SELECT uid, name FROM user WHERE uid IN (SELECT id FROM profile WHERE CONTAINS('Peter'))
How can I know which user is my friend (<-- sounds silly)?
As far as I know, the following FQL can check whether the search result user is friend of me, or not:
SELECT uid2 FROM friend WHERE uid1 = me()
Apart from executing the 2nd query for each of the search result, is there a way to combine both query?
Update: Since FQL is going to be deprecated, Graph API solution is also welcomed.
I am trying to get all links shared by a user's friends I tried all of the queries and requests from the below questions,
How do I get a friend's links with Facebook's graph api?
Finding who shared a link publicly and finding who reshared a given link
Facebook API: All links shared by all friends?
get shared links on facebook newsfeed
but unable to figure out what would be the exact FQL or the request URL to get all links shared from my friends from a defined past interval. I am kind of a newbie with the graph API and FQL, so kindly help me in figuring out a way to do this.
I tried a simple query
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls FROM link WHERE owner IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 100)
but I get
{
"error": "Request failed"
}
as the response from the API Explorer.
Your query is too long for FQL to construct the answer. If you'll try this:
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls
FROM link WHERE owner IN
(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 10)
(the same query, only limit set to 10 instead of 100) FQL explorer will think ~5-8secs but then give you back the result. Or if you will not receive the result, you have to reduce limit again.
So you have 2 choices:
You can lower you limit from 100 to 10 or less and run your query without changes
You can run query
SELECT uid2 FROM friend WHERE uid1 = me()
and then for each received friend ID run another query
SELECT link_id, owner, owner_comment, created_time, title, summary, url, image_urls
FROM link WHERE owner = FRIEND_ID
How can I get a list of profiles via Facebook Graph API or FQL ordered by their relevance to the current user just as the result I would get after a name search within Facebook?
A graph API search like /search?type=user&fields=name&q=NAME with my current access token returns an irrelevant list of NAMEs while a search within Facebook for NAME returns most probable matches for me, starting from friends, friends of friends with most mutual friends, etc.
With and FQL query like
SELECT uid, name FROM user
WHERE strpos(name, 'NAME') >=0
AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
ORDER BY mutual_friend_count DESC
I can search within my friends and get the results ordered by mutual friend count. But I want to have non-friends in the result list as well.
How can I implement a Graph or FQL search query to get a similar set of profiles ordered by relevance to the current user making the query?
I am trying to retrieve all my friends' likes using FQL. But I am not getting all the likes only those pages which have "is_community_page" value true are being returned. Here's my FQL query
SELECT uid, page_id FROM page_fan WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
There is a max limit of 5000 results per FQL query that Facebook imposes before the results are trimmed for Privacy preferences of users. You can read this blog post about the same.
Facebook FQL retrieve a link to have full likes list and a samples list (quite unuseful), the point is not the limit of result, the point is fql has a different approach to list this data.
I stepped into it as well, trying to find a solution atm
I need to find a profile in a specific town or nation, but I just
found a way to get profiles by checking locale column in my Facebook
query. Is it possible to retrieve a user id and link with town and
other location information, but is it not possible to retrieve
profiles by town?
Using the Facebook API, it is not possible to query by locale since it's not indexed (see: http://developers.facebook.com/docs/reference/fql/user/ and look for column names with a * star). According to the documentation the only columns you can search on with the API is uid, username, and name.
If you only want to query over the friends associated with the provided access token, you can do this FQL query:
query = {}
# first get friends which have provided a current location
query['friends'] = "SELECT uid, name, current_location FROM user \
WHERE uid IN (SELECT uid1 FROM friend WHERE uid2=me()) \
AND current_location"
# then get the latlongs corresponding to their current location
query['latlong'] = "SELECT page_id, latitude, longitude FROM place \
WHERE page_id IN (SELECT current_location.id FROM #friends)"
You can use this information to assign a latlong to each friend. The filtering must be done client-side ... I don't think there is another way.
NOTE: Of course this needs the friends_location permission.
Using the Graph API, you can search profiles using text place names like so:
https://graph.facebook.com/search?q=new%20york&type=user&access_token=???
(Replace ??? with your current access_token.)
Not clear to me exactly what profile text is matched against, so you may end up finding people that have a name similar to your search query or that are just talking about a place. Best to check the users specified location as a second filter. Hope that helps.