Facebook Graph API: search people by city - facebook

I'm trying to find people either from particular city or who live in that city. Is there an API for this purpose?
When I use Facebook page, I can type in "People who live in Rome, Italy" (which is translated to URL https://www.facebook.com/search/115353315143936/residents/present) and it shows me all people who currently live in Rome. Using web page I can also search people by name and then add additional filter by city.
Can I do something similar with Graph API?

You can only search by name with the API: https://developers.facebook.com/docs/graph-api/using-graph-api#search - there is no way to get the same kind of search than on facebook.com.

you can add center and distance in the query
this comes from the documentation, you can change the type to type=user
GET graph.facebook.com
/search?
q=coffee&
type=place&
center=37.76,-122.427&
distance=1000

Related

Query for pages of a specific type on Facebook

I need to have something like http://fanpagelist.com/category/musicians/ in my web app.
Basically I need to allow users to search through Facebook pages of musician/band category and sort by number of fans.
The closest I got was with this FB Graph API call:
search?q=musician&type=page&limit=25&after=MjQZD&fields=name,fan_count,category
But that is searching for pages that have 'musician' in the name, not in the category field.
Any idea? It must be possible since fanpagelist can do it...
There is no way to filter the results from that search endpoint directly.
You are limited to the options described under https://developers.facebook.com/docs/graph-api/using-graph-api/#search, and that basically means you can search by name, but nothing else.
So you will need to filter the results on your end.

How to get all user's likes using facebook's graph API

How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.

Facebook search form a term with geolocation

Facebook has the Keyword Insights API that solves this question, but it's not available for all developers - except for some partners and we have this example:
SELECT location_results FROM keyword_insights WHERE term='Obama' AND country='US'
From https://developers.facebook.com/docs/keyword_insights/#examples
But without have access to Keyword Insights API is it possible search for user posts that have the term "Obama" in coordinates 39.781762,-89.649854 with a radius of 50 miles?
Thanks in advance.
No. It's not possible to get insights from the user posts without an access to the Keyword API.
An alternate can be to use the Facebook Graph API Search. It allows you to narrow your search to a specific location and distance. For example, you can specify the latitude and longitude using the center parameter in the query:
https://graph.facebook.com/search?q=obama&type=posts&center=37.76,-122.427
&distance=1000&access_token=<token>
You can parse the result obtained from it and generate insights on your own.

Fetch location or coordinates specfic posts using facebook search api

Is there are way to fetch location/coordinate specific public posts using the facebook search api (https://graph.facebook.com/search/?q=KEYWORD&type=post ...)? I want this to be a general search query, without any user authorization.
I tried using https://graph.facebook.com/search?type=location&center=37.76,-122.427&distance=1000&access_token=... , but this requires access_token and returns objects(not posts) posted only by friends of the user whose access token is used for querying.
I also tried https://graph.facebook.com/search?q=samsung&type=post&center=12.9833,77.5833&distance=1000&access_token=[I-USED-ANY-ACCESS-TOKEN], but I dont think this is giving me the location specific results as I am not receiving any loc info in the json response.
Are there any free data sources/APIs that can provide me location/coordinate/ip specific posts/data/tweets/feeds, etc from the web / social networking websites?
It is possible to walk the FB graph to get such places and their coordinates for types like event, place, checkin. For example:
Search (link):
https://developers.facebook.com/tools/explorer?method=GET&path=search%3Fq%3Dconference%26type%3Devent
Then pick one of the results and do (link):
https://developers.facebook.com/tools/explorer?method=GET&path=463944956965055
Then lookup the venue id's coordinates (link):
https://developers.facebook.com/tools/explorer?method=GET&path=199344279273
Check the FQL table definitions to verify that location coordinates are provided.
The accepted answer doesn't really answer the question.
The answer is no, there isn't a way to search for general posts by location (excluding your friends). It's probably to protect user privacy.

Find related facebook interests using graph API

I'm trying to figure out a way find related interests on Facebook. E.g. I want to search for Cityville and result should be Farmville, Castleville etc.
Is there an API to support this, what are the alternatives?
You can search the JSON result by the Graph API with the url https://graph.facebook.com/me/likes?access_token={your_token_here}, replacing the "me" with the Facebook User ID/Name.
If you are looking for pages search, you can use the same API, with the url https://graph.facebook.com/search?q={keyword}&type=page&access_token={your_token_here}.