我怎样才能获得在 Twitter 上发布的四方签到的位置(纬度,经度)? [英] How can I get the position (lat, lon) of a foursquare checkin posted on twitter?

查看:55
本文介绍了我怎样才能获得在 Twitter 上发布的四方签到的位置(纬度,经度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  1. I search with the twitter API all the public tweets with "4sq.com":

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

所以我得到了在 Twitter 上实际分享的 Foursquare 上的所有签到信息.

so I get all the check-in on Foursquare that actually shared on Twitter.

{"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) 我可以在地图上看到签到的位置(如果我在网页上显示链接).

With these tweets, Foursquare provides a link (like this one: http://t.co/DIKdYGwD) where I can see the position of the check-in on a map (if I display the link on a webpage).

如何以编程方式直接从推文列表中获取纬度和经度?

How can I get the latitude and longitude programmaticly directly from the list of tweets?

想法:我是否需要获取网页上的链接并对其进行分析以获取经纬度?

Idea: Do I need to fetch the link on a webpage and analyse it to get the latitude and longitude?

我不想使用 Twitter 地理编码

I don't want to use Twitter geocode

推荐答案

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

You already have what you want, look at the "geo" section in sample of search output you posted. It's null because it is not filled (twitter user forget to enable twitter location in settings and all locations from foursquare are ignored by twitter).

您可以按位置过滤推文,查看 Twitter 开发文档.

You can filter twits by location, look at the Twitter Dev documentation.

更新:

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

If you want to get location even in case when it is not stored to twit, you have to perform request to foursquare short link and parse venue information (you can steal location also). Look at the source of the sample 4sq.com page (small part):

...
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 地址的请求.这就是为什么这个解决方案很丑的原因.

Unfortunately, Foursquare team can change the format of the page or limit requests from IP Address without any notes. That's why this solution is ugly.

UPD2

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

See answer from @MikeLewis, I've missed that Foursquare API supports requesting information by checking id.

这篇关于我怎样才能获得在 Twitter 上发布的四方签到的位置(纬度,经度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆