Search profiles by city in Facebook API - facebook-graph-api

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.

Related

Using USERNAME as part of a condition in Power BI

Let's suppose I've got a simple table with two columns: user, value
Is it possible to use the function USERNAME within a code in order to filter the information that corresponds only to the user that is logged? Something like this:
Select username, value
from table
where username = USERNAME()
And show only the information that every user should see.
Regards
Yes, it's possible. You can use the USERNAME or USERPRINCIPALNAME as a filter in CALCULATE or as part of a Row Level Security filter.

Facebook API: Getting list of profiles ordered by relevance

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?

FQL query using Facebook Graph API

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

Facebook Graph-Api: Get name of pages

Iam new to the Facebook graph api.
I want to get all the names of the pages with more then a milion likes
This is my fql:
fql?q=SELECT name FROM page WHERE fan_count > 1000000
But i don't think that this is the right way. Is there a way to get all the names of the pages that meet the fql criteria?
No, the page FQL table is indexed only on id, name and username, not on fan count, so you can't query like this

How to remove the meta data field from multi id queries

I am using the open_graph Explorer tool to test this out and I need to be able to get the first_name, last_name and installed from 1000 users. At the moment I group up the users in grouped of 50 for a single query and batch them into up to 20 queries in a batch request.
A single query looks as follows
?ids=100003825998801,100003825998802,547884299,100003825998803,100003825998804,100003825998805,100003825998806&fields=first_name,last_name,installed
Now, the question is, when you use multiple ids in a single query like I did, facebook seems to "force" certain fields on you, large fields, such as "metadata" and "fields". Is it possible to remove these fields from the result set of the query?
Also, any advice on how to make this more efficient would also be great.
Thank.
Have you considered using FQL instead …?
SELECT first_name, last_name, is_app_user FROM user
WHERE uid IN (100003825998801,100003825998802,547884299,100003825998803,
100003825998804,100003825998805,100003825998806)
– that gives you just the info you want, you only have to watch out for the fact that the installed field is named is_app_user in FQL.