从Foursquare API获取特定城市和类别的POI

时间:2014-11-24 15:19:43

标签: php foursquare

我想使用Foursquare-API来获取特定城市的场地。 API有两个端点可以帮助我解决我的问题:
venue/explorevenue/search

现在的问题是,它们都缺少我需要的另一个端点所具有的功能。例如,我无法使用探索端点,因为我无法将类别ID传递给foursquare api,只能在给定的类别中进行搜索。

所以现在我已经拥有来使用搜索端点,但搜索端点还有另一个问题。意图参数。 intent参数接受checkin, browse, global, match

checkin发现用户将在当前时刻登记的pois。问题:我想在晚上经营一个cronjob,因此它永远不会找到博物馆,因为它可能在晚上关闭。

browse有问题,我必须传递一个radius参数。但由于不是每个城市都有相同的半径,我也会在搜索请求中找到其他城市的结果。例如,如果我在科隆搜索pois,并且半径为30km,我也会在杜塞尔多夫找到POI。但在其他一些城市,30公里的半径是一个很好的,我只会在给定的城市找到POI。我无法确定我的半径是否正确。

global搜索独立于该位置,因此它也无用

match不包含类别,因此它也无用

好的,让我们一起总结,我需要做什么

我需要找到某个城市的地点,并且只有特定的类别! 我在这里建立了自己的网址来查询来自foursquare的数据

https://api.foursquare.com/v2/venues/search?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&v=20141124&categoryId=4d4b7105d754a06374d81259,503288ae91d4c4b30a586d67,4bf58dd8d48988d1c8941735,4bf58dd8d48988d14e941735,4bf58dd8d48988d152941735,4bf58dd8d48988d107941735,4bf58dd8d48988d142941735,4bf58dd8d48988d169941735&intent=browse&radius=5000&limit=50&near=35.6894875,139.69170639999993

现在返回东京的场地:(我将其限制为3,所以我们不会在这里显示太多数据)

{
   "meta":{
      "code":200
   },
   "response":{
      "venues":[
         {
            "id":"4b7af3d1f964a520e3472fe3",
            "name":"伊勢丹 新宿店 (Isetan Shinjuku)",
            "contact":{
               "phone":"+81333521111",
               "formattedPhone":"+81 3-3352-1111"
            },
            "location":{
               "address":"新宿3-14-1",
               "lat":35.69167888630371,
               "lng":139.70466434955597,
               "postalCode":"160-0022",
               "cc":"JP",
               "city":"新宿区",
               "state":"東京都",
               "country":"Japan",
               "formattedAddress":[
                  "新宿3-14-1",
                  "新宿区, Tōkyō",
                  "160-0022",
                  "Japan"
               ]
            },
            "categories":[
               {
                  "id":"4bf58dd8d48988d1f6941735",
                  "name":"Kaufhaus",
                  "pluralName":"Kaufhäuser",
                  "shortName":"Kaufhaus",
                  "icon":{
                     "prefix":"https:\/\/ss3.4sqi.net\/img\/categories_v2\/shops\/departmentstore_",
                     "suffix":".png"
                  },
                  "primary":true
               }
            ],
            "verified":false,
            "stats":{
               "checkinsCount":38525,
               "usersCount":14542,
               "tipCount":104
            },
            "url":"http:\/\/www.isetan.co.jp\/icm2\/jsp\/store\/shinjuku\/",
            "specials":{
               "count":0,
               "items":[

               ]
            },
            "hereNow":{
               "count":0,
               "summary":"Keiner hier",
               "groups":[

               ]
            },
            "referralId":"v-1416841962"
         },
         {
            "id":"4b6a8c00f964a5204fd82be3",
            "name":"東急 田園都市線 渋谷駅",
            "contact":{
               "phone":"+81354585143",
               "formattedPhone":"+81 3-5458-5143"
            },
            "location":{
               "address":"道玄坂2-1-1",
               "lat":35.65325468817092,
               "lng":139.69734217064342,
               "cc":"JP",
               "city":"渋谷区",
               "state":"東京都",
               "country":"Japan",
               "formattedAddress":[
                  "道玄坂2-1-1",
                  "渋谷区, Tōkyō",
                  "Japan"
               ]
            },
            "categories":[
               {
                  "id":"4bf58dd8d48988d129951735",
                  "name":"Bahnhof",
                  "pluralName":"Bahnhöfe",
                  "shortName":"Bahnhof",
                  "icon":{
                     "prefix":"https:\/\/ss3.4sqi.net\/img\/categories_v2\/travel\/trainstation_",
                     "suffix":".png"
                  },
                  "primary":true
               }
            ],
            "verified":false,
            "stats":{
               "checkinsCount":51145,
               "usersCount":6686,
               "tipCount":21
            },
            "specials":{
               "count":0,
               "items":[

               ]
            },
            "hereNow":{
               "count":0,
               "summary":"Keiner hier",
               "groups":[

               ]
            },
            "referralId":"v-1416841962"
         },
         {
            "id":"543365cd498e6a226ce59c11",
            "name":"la kagu ラカグ",
            "contact":{
               "phone":"+81352276977",
               "formattedPhone":"+81 3-5227-6977",
               "twitter":"la_kagu",
               "facebook":"470802349690219",
               "facebookUsername":"lakagu.kagurazaka",
               "facebookName":"ラカグ la kagu"
            },
            "location":{
               "address":"矢来町67",
               "lat":35.70377775661292,
               "lng":139.73318235755823,
               "postalCode":"162-0805",
               "cc":"JP",
               "city":"Tokyo",
               "state":"東京都",
               "country":"Japan",
               "formattedAddress":[
                  "矢来町67",
                  "新宿区, Tōkyō",
                  "162-0805",
                  "Japan"
               ]
            },
            "categories":[
               {
                  "id":"4bf58dd8d48988d1f8941735",
                  "name":"Möbel- \/ Einrichtungsgeschäft",
                  "pluralName":"Möbel- \/ Einrichtungsgeschäfte",
                  "shortName":"Möbel \/ Einrichtung",
                  "icon":{
                     "prefix":"https:\/\/ss3.4sqi.net\/img\/categories_v2\/shops\/furniture_",
                     "suffix":".png"
                  },
                  "primary":true
               }
            ],
            "verified":false,
            "stats":{
               "checkinsCount":468,
               "usersCount":429,
               "tipCount":5
            },
            "url":"http:\/\/www.lakagu.com",
            "specials":{
               "count":0,
               "items":[

               ]
            },
            "hereNow":{
               "count":0,
               "summary":"Keiner hier",
               "groups":[

               ]
            },
            "referralId":"v-1416841962"
         }
      ],
      "geocode":{
         "what":"",
         "where":"35.6894875,139.69170639999993",
         "feature":{
            "cc":"JP"
         },
         "parents":[

         ]
      }
   }
}

现在有很多问题:

  1. 城市名称使用国家/地区语言(非英语)
  2. 此搜索的foursquare API返回Shibuya作为一个特殊病房的城市(例如),而不是城市和东京。然而,在德国,这个城市就像科隆一样,州是州,像北莱茵 - 威斯特法伦州。
  3. 这导致了一个问题,即我无法轻松比较城市以查看POI是否在请求的城市中。然而,我可以检查城市或州是否匹配,但每个国家的情况可能不同,所以我认为这是一个问题。

    那么,只有特定类别的城市才能获得与时间,地点等无关的特定类别的最佳方法,并过滤掉非要求城市的城市中的pois?

0 个答案:

没有答案