foursquare 场地结果语言环境

foursquare venue result locale

https://developer.foursquare.com/overview/versioning 它说:

You can specify the locale by setting the Accept-Language HTTP header in your request. Alternatively, you can add a locale=XXX parameter to your request but HTTP header specification is preferred. We currently support en (default), es, fr, de, it, ja, th, tr, ko, ru, pt, and id.

If nothing is specified, for geographical entities (e.g., city names), we'll fall back to using the language that's most popular in the country for that venue.

现在,我们如何获得 API 结果的语言环境?如果我使用 tr 语言环境进行查询,它可能会使用 en 或其他后备语言环境回答我。我在结果和响应 headers.

中都找不到它

我需要它来缓存并向用户显示正确的数据。例如,我网站的后备语言是 en,但 API 可能会给我 de

谢谢。


编辑这是我试图讲述的一个例子;

URL:

https://api.foursquare.com/v2/venues/4adcda50f964a520354121e3
?client_id=[client_id]&client_secret=[client_secret]&v=20161115&locale=tr

Headers:

array (
   'Accept-Language' => 'tr',
   'Accept' => 'application/json'
)

结果(裁剪了一些不相关的项目):

{
  "meta": {
    "code": 200,
    "requestId": "582bfe9e1ed21964a18d3aab"
  },
  "response": {
    "venue": {
      "id": "4adcda50f964a520354121e3",
      "name": "La Pedrera (Casa Milà) (Casa Milà 'La Pedrera')",
      "contact": {
        "phone": "+34902202138",
        "formattedPhone": "+34 902 20 21 38",
        "twitter": "catfundacio",
        "facebook": "429182007214758",
        "facebookUsername": "lapedrera.barcelona",
        "facebookName": "La Pedrera-Casa Milà"
      },
      "location": {
        "address": "Pg. Gràcia, 92",
        "crossStreet": "Carrer Provença",
        "lat": 41.39509128050475,
        "lng": 2.1618343621091296,
        "postalCode": "08008",
        "cc": "ES",
        "city": "Barselona",
        "state": "Cataluña",
        "country": "İspanya",
        "formattedAddress": [
          "Pg. Gràcia, 92 (Carrer Provença)",
          "08008 Barselona Catalonia",
          "İspanya"
        ]
      },
      "canonicalUrl": "https:\/\/foursquare.com\/v\/la-pedrera-casa-mil%C3%A0\/4adcda50f964a520354121e3",
      "categories": [
        {
          "id": "4bf58dd8d48988d12d941735",
          "name": "Anıt \/ Abide",
          "pluralName": "Anıtlar \/ Abideler",
          "shortName": "Abide",
          "icon": {
            "prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/building\/government_monument_",
            "suffix": ".png"
          },
          "primary": true
        },
        {
          "id": "4bf58dd8d48988d130941735",
          "name": "Bina",
          "pluralName": "Binalar",
          "shortName": "Bina",
          "icon": {
            "prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/building\/default_",
            "suffix": ".png"
          }
        }
      ],      
      "description": "La Pedrera (Casa Milà) és un edifici construït per Antoni Gaudí i declarat Patrimoni de la Humanitat. Actualment és la seu de la Fundació Catalunya-La Pedrera.",
      "storeId": "",
      "tags": [
        "gallery",
        "gaudi",
        "modernisme",
        "museum",
        "photobooth",
        "sicted"
      ],
      "shortUrl": "http:\/\/4sq.com\/72NCMi",
      "timeZone": "Europe\/Madrid",
      "hours": {
        "status": "09:00'e kadar kapalı",
        "isOpen": false,
        "isLocalHoliday": false,
        "timeframes": [
          {
            "days": "Pzt\u2013Paz",
            "includesToday": true,
            "open": [
              {
                "renderedTime": "09:00\u201321:00"
              }
            ],
            "segments": [

            ]
          }
        ]
      },
      "attributes": {
        "groups": [
          {
            "type": "wifi",
            "name": "Kablosuz Bağlantı",
            "summary": "Ücretsiz Wi-Fi",
            "count": 1,
            "items": [
              {
                "displayName": "Kablosuz Bağlantı",
                "displayValue": "Ücretsiz"
              }
            ]
          }
        ]
      },
      "bestPhoto": {
        "id": "55672a92498ec352981dd144",
        "createdAt": 1432824466,
        "source": {
          "name": "Foursquare Web",
          "url": "https:\/\/foursquare.com"
        },
        "prefix": "https:\/\/irs2.4sqi.net\/img\/general\/",
        "suffix": "\/39082263_M0PK-NTv3A-0tI4j_aEIp5k6BEkliQTkMXS9TIPg_NQ.jpg",
        "width": 620,
        "height": 478,
        "visibility": "public"
      }
    }
  }
}

addresses, categories, some of the names, timeframes, attributes 部分实际上是 土耳其语 ,但描述和大部分名称使用 fallback/local 语言,即 西班牙语 在这种情况下。

API 响应中未指定语言环境。

如果您未在 Accept-Language HTTP header 中指定任何内容,则响应将默认为该国家/地区最流行的语言。但是,如果您确实指定了本地 API 将不会回退到任何其他内容。

如果您的网站语言是英语,您可以在 Accept-Language HTTP header 中指定 en,API 也会为您提供英语。