根据位置查找推特用户

Find twitter users based on their location

我需要根据位置查找 Twitter 用户。理想情况下应该是他们的当前位置,但如果只是他们原来的位置,也可以。例如,如果某人来自巴西,但今天他们在德国,我希望能够找到他们作为 "in Germany" 推特用户。

此外,如果可能的话,我希望能够知道他们现在所在的城市,而不仅仅是国家。

我可以通过 Twitter API 做到这一点吗?如何?

我不想使用任何直接将此作为服务提供的第 3 方服务,但是,使用我自己可以间接找到其当前位置的第 3 方服务是可以的。例如,如果他们最近在 Facebook 上发布了一张照片 "I'm already in Germany, yeaahhhh" -- 诸如此类。当然,我更喜欢推特API。

您基本上要寻找的是地理标记信息。但是,您想根据用户的位置查找用户。你会得到的答案不是简单的“是”或“否”,它实际上是基于你想要完成的事情。但是,由于您询问的是 Twitter API,因此 Twitter API 不能 做您想做的事,但有办法解决它。

您的问题主要集中在如何找到给定位置的用户。对于下面的示例,假设位置是“德国柏林”

目前,根据您的要求,Twitter API 有两种方法可以让您获取基于位置的信息。

User Search Method (users/search):

根据 Twitter 的文档,它指出此功能将 return 您的用户基于您提供的任何查询。引用:

[users/search] Provides a simple, relevance-based search interface to public user accounts on Twitter. Try querying by topical interest, full name, company name, location, or other criteria. Exact match searches are not supported.

但是,根据他们的推文,位置信息不是。相反,它基于他们的个人资料位置信息(用户在首次创建 Twitter 个人资料时输入的信息)。

因此,使用 柏林,DE 示例:Jason 住在美国加利福尼亚州(他的个人资料反映了他来自加利福尼亚州圣何塞的事实),但他是最近访问柏林并在那里积极发推文。包括用他的位置和所有标记他的推文。现在,如果您使用查询 柏林,德国 执行 users/search,您将不会在结果中找到 Jason,因为他的个人资料位置设置为加利福尼亚州圣何塞。

Tweets Search Method (search/tweets):

根据 Twitter 的文档,此方法将根据您提供的任何查询(包括位置)return 向您发送推文(最多 450 条具有 APP 授权的推文)。使用 geocode 查询,您可以在给定位置找到所需的信息。引用:

Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by “latitude,longitude,radius”, where radius units must be specified as either “mi” (miles) or “km” (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly. A maximum of 1,000 distinct “sub-regions” will be considered when using the radius modifier.

柏林,德国 为例,如果您使用此方法,您实际上会找到 Jason 的推文,因为它们被标记为柏林。此方法不会 return 您想要的profile/user 信息。但是,您可以利用此方法获取用户信息。

本质上,您可以解析所有推文并收集用户 ID,这正是您想要的。这是通过 API.

可见和访问的最佳解决方案