How can I get the position (lat, lon) of a foursquare checkin posted on twitter?

前端 未结 2 2031
南笙
南笙 2021-02-10 04:30
  1. I search with the twitter API all the public tweets with \"4sq.com\":

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

so I get all the check-

2条回答
  •  死守一世寂寞
    2021-02-10 05:19

    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).

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

    UPD:

    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}}};
    ...
    

    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

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

提交回复
热议问题