如何使用Graph-API在Facebook上搜索特定位置的所有用户

问题描述:

我有一个项目,必须在Facebook上搜索所有人. 确定位置,然后对数据应用进一步的过滤器.我的问题是:

I have a project where I have to search Facebook for all people at a certain location and then apply further filters to the data. My problem and question is:

如何使用Graph API获取初始数据?

我知道使用Facebook本身的搜索字段是可能的.只需输入所有居住在???中的人"返回人员列表. 我在Facebook的Graph-API中找不到这种功能.这是我尝试过的:

I know that it is possible, using the search field in Facebook itself. Just typing "All people living in ???" returns a list of people. I couldn't find such functionality in the Graph-API of Facebook. Here is what I tried:

我修改了标准搜索请求的一些参数

I modified some parameters of the standard search request

  • search?type=user&center=52.946758,-1.172882&distance=1000
  • search?type=user&center=Nottingham&distance=1000
  • search?type=user&center=52.946758,-1.172882&distance=1000
  • search?type=user&center=Nottingham&distance=1000

这就是我得到的:

{
  "error": {
    "message": "No node specified", 
    "type": "GraphMethodException", 
    "code": 100
  }
}


location而不是center


Using a similar query with location instead of center

  • search?type=user&location=Nottingham&distance=1000
  • search?type=user&location=52.946758,-1.172882&distance=1000
  • search?type=user&q=&location=Nottingham
  • search?type=user&location=Nottingham&distance=1000
  • search?type=user&location=52.946758,-1.172882&distance=1000
  • search?type=user&q=&location=Nottingham

只有一个令人困惑的错误,我写的位置是错误的

and only got a confusing error that the location I wrote is wrong

{
  "error": {
    "message": "(#160) Invalid coordinates.  Coordinates must contain at least latitude and longitude.", 
    "type": "OAuthException", 
    "code": 160
  }
}


然后使用坐标为query参数搜索用户将返回空结果.


Then searching for a user with the coordinates as query parameter returned an empty result.

  • search?type=user&q=52.946758,-1.172882&distance=1000

{"data": []}

然后我尝试搜索正确的位置以传递给查询的location参数

Then I tried to search for a correct location to pass to the location parameter of the query

  • search?type=location&q=52.946758,-1.172882

我只有一个弃用错误

{
  "error": {
    "message": "(#12) location search is deprecated for versions v2.0 and higher", 
    "type": "OAuthException", 
    "code": 12
  }
}


我不知道该怎么做.如果有人可以告诉我如何获取此信息,那将有所帮助 我很多,因为我不知道下一步该怎么做.


I don't know how to get to this. If someone could tell me, how to get this information, it would help me a lot, since I don't know what to try next.

我发现这个问题与我的问题相似,但是被接受的答案并未真正回答该问题 Facebook搜索API-根据位置列出所有用户吗?

I have found this question similar to my problem, but the accepted answer isn't really answering the question Facebook Search API - List all users based on location?

您可以搜索位置或搜索用户,但是绝对不能搜索区域中的所有用户". Facebook上的Graph搜索可以处理更多您使用API​​无法获得的功能.考虑一下隐私,我什至不希望任何应用程序不知道我是否在附近,而无需授权该应用程序;)

You can either search for a location OR search for a user, but you can definitely not search for "all users in an area". The Graph search on Facebook can handle a lot more things that you will never be able to get with the API. Think about privacy, i would not want any app to know if i am nearby, without even authorizing the App ;)

Facebook文档: https://developers .facebook.com/docs/graph-api/using-graph-api/v2.2#search

Facebook docs: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search

要获取用户所在的位置,您需要查看用户参考:

For getting the locatoin where the user is living, you need to check out the user reference: https://developers.facebook.com/docs/graph-api/reference/v2.2/user

其中有一个位置"字段,您需要授权具有"user_location"权限的用户才能获取该信息.无法从任何用户那里获得该信息.仅仅因为您可以在Facebook上看到数据并且该数据是公开的,并不意味着您可以使用某个应用访问该数据,出于隐私方面的考虑,这只有通过授权用户才能实现.

There is a "location" field in there, you need to authorize a user with the "user_location" permission to get that information. It is not possible to get that information from any user. Just because you can see data on Facebook and it is public does not mean you can access it with an App, for privacy reasons this is only possible by authorizing the user.

不允许在没有应用程序的情况下进行抓取,请检查抓取条款: https://www .facebook.com/apps/site_scraping_tos_terms.php

Scraping without an App is not allowed btw, check out the scraping terms: https://www.facebook.com/apps/site_scraping_tos_terms.php