我如何才能在推特上得到一个四方形签到的位置(lat,lon)


  1. 我用推特API搜索所有带有"4sq.com"的公开推文:

    http://search.twitter.com/search.json?q=4sq.com

所以我在Foursquare上收到了所有在推特上分享的入住信息。

{"created_at":"Sun, 08 Jan 2012 20:05:27 +0000","from_user":"fenavergara","from_user_id":50876086,"from_user_id_str":"50876086","from_user_name":"Fernanda Vergara Ch","geo":null,"id":156104246239051776,"id_str":"156104246239051776","iso_language_code":"lt","metadata":{"result_type":"recent"},"profile_image_url":"http://a2.twimg.com/profile_images/1708744785/image_normal.jpg","profile_image_url_https":"https://si0.twimg.com/profile_images/1708744785/image_normal.jpg","source":"<a href="http://foursquare.com" rel="nofollow">foursquare</a>","text":"I'm at Roca Roja (Antofagasta) http://t.co/DIKdYGwD","to_user":null,"to_user_id":null,"to_user_id_str":null,"to_user_name":null},{"created_at":"Sun, 08 Jan 2012 20:05:27 +0000","from_user":"Fabioland76","from_user_id":357326176,"from_user_id_str":"357326176","from_user_name":"Fabio Landini","geo":null,"id":156104246104821760,"id_str":"156104246104821760","iso_language_code":"no","metadata":{"result_type":"recent"},"profile_image_url":"http://a3.twimg.com/profile_images/1506958638/profiloJPG_normal.jpg","profile_image_url_https":"https://si0.twimg.com/profile_images/1506958638/profiloJPG_normal.jpg","source":"<a href="http://foursquare.com" rel="nofollow">foursquare</a>","text":"I'm at Burger King (Gallerie Cantoni, Legnano) http://t.co/rU1jIJ4A","to_user":null,"to_user_id":null,"to_user_id_str":null,"to_user_name":null}

通过这些推文,Foursquare提供了一个链接(如下所示:http://t.co/DIKdYGwD)在那里我可以在地图上看到办理登机手续的位置(如果我在网页上显示链接)。

如何通过程序直接从推文列表中获取纬度和经度?

想法:我需要在网页上获取链接并对其进行分析以获得纬度和经度吗?

编辑:我不想使用Twitter地理编码

如果您想使用foursquare API,这里实际上有一个更好的解决方案。这不依赖于用户是否启用了Twitter的地理标记。

您已经注意到,状态更新中的链接重定向到一个四方页面。您可能会注意到url中有两条关键信息,而不是截屏。签入id和一个名为s(用于签名)的参数,该参数允许您通过foursquare的API访问签入。

https://foursquare.com/dens/checkin/4f0b3676e4b0e8ed3a590e41?s=MWHM3-0BsLXIJprfbALvOM606ZE&ref=tw

例如,在上面的url中,签入id为4f0b3676e4b0e8ed3a590e41,而签名为MWHM3-0BsLXIJprfbALvOM606ZE

使用/checkins端点,您可以获得完整的签入详细信息(包括场地的纬度/经度)。Dox在此:https://developer.foursquare.com/docs/checkins/checkins

您已经有了想要的东西,请查看您发布的搜索输出示例中的"geo"部分。它是null,因为它没有被填充(twitter用户忘记在设置中启用twitter位置,来自foursquare的所有位置都被twitter忽略)。

您可以按位置过滤推特,请参阅推特开发人员文档。

UPD:

如果你想获得位置,即使它没有存储到twit,你也必须执行对四方短链接的请求并解析场地信息(你也可以窃取位置)。查看示例4sq.com页面的来源(小部分):

...
options['lat'] = 42.98758759825106;
options['lng'] = -71.50742411613464;
options['fuzzy'] = false;
options['venue'] = {"id":"v4f08df964fc62d44946f058a","venue":{"id":"4f08df964fc62d44946f058a","name":"ABC News u2013 WMUR Debate","contact":{"twitter":"MittRomney"},"location":{"address":"100 St Anselm Drive","lat":42.98758759825106,"lng":-71.50742411613464,"city":"Manchester","state":"NH"},"categories":[{"id":"4bf58dd8d48988d1af941735","name":"College Auditorium","pluralName":"College Auditoriums","shortName":"Auditorium","icon":{"prefix":"https://foursquare.com/img/categories/education/default_","sizes":[32,44,64,88,256],"name":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":7,"usersCount":7,"tipCount":1}}};
...

不幸的是,Foursquare团队可以在没有任何注释的情况下更改页面格式或限制来自IP地址的请求。这就是为什么这个解决方案是丑陋的。

UPD2

请参阅@MikeLewis的回答,我错过了Foursquare API支持通过检查id来请求信息。