Skip to content

AccuWeather

Accuweather는 전 세계에 기상 예보 서비스를 제공하는 미디어 회사입니다. With AccuWeather, you can enrich and personalize your marketing campaigns, as well as automate translations through the use of Braze Connected Content.

This integration is maintained by AccuWeather.

필수 조건

사용 가능한 Accuweather API

다음은 Braze 캠페인 및 캔버스에서 참조할 수 있는 AccuWeather API입니다.

연결된 콘텐츠 예시

다음 예제에서는 사용자의 미국 내 우편번호의 현재 조건에 따라 두 가지 다른 유형의 메시지를 표시하는 연결된 콘텐츠 호출을 보여줍니다. Accuweather 위치 및 현재 조건 API 엔드포인트가 사용됩니다.

1
2
3
4
5
6
7
8
9
10
11
{% connected_content http:///dataservice.accuweather.com/locations/v1/postalcodes/{{${country}}}/search?q={{custom_attribute.${Zip Code}}}&apikey={your API key} :save location_info %}

{% connected_content http://dataservice.accuweather.com/currentconditions/v1/{{location_info[0].Key}}?apikey={your API key} :save local_weather %}

{% if {{local_weather[0].WeatherText}} == 'Cloudy' %}
No sunscreen needed :)
{% elsif {{local_weather[0].WeatherText}} == 'Rain' %}
It's raining! Grab an umbrella!
{% else %}
Enjoy the weather!
{% endif %}

연결된 콘텐츠 푸시 메시지 "비가 오고 있어요!" Grab an Umbrella!" shown on an Android device

다음 예제에서 두 개의 연결된 콘텐츠 호출에 대한 분석을 확인할 수 있습니다.

위치 API 예시

첫 번째 connected_content 태그 내에서 위치 API에 대한 GET 요청이 수행됩니다. 이 예제에서는 우편번호 커스텀 속성이 없는 경우 사용자의 {{${city}}}를 대신 활용할 수 있습니다.

1
{% connected_content http://dataservice.accuweather.com/locations/v1/postalcodes/{{${country}}}/search?q={{custom_attribute.${Zip Code}}}&apikey={your API key} :save location_info %}

다음은 Accuweather가 JSON 객체로 반환할 예입니다:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
[
  {
    "Version": 1,
    "Key": "41333_PC",
    "Type": "PostalCode",
    "Rank": 35,
    "LocalizedName": "Seattle",
    "EnglishName": "Seattle",
    "PrimaryPostalCode": "98102",
    "Region": {
      "ID": "NAM",
      "LocalizedName": "North America",
      "EnglishName": "North America"
    },
    "Country": {
      "ID": "US",
      "LocalizedName": "United States",
      "EnglishName": "United States"
    },
    "AdministrativeArea": {
      "ID": "WA",
      "LocalizedName": "Washington",
      "EnglishName": "Washington",
      "Level": 1,
      "LocalizedType": "State",
      "EnglishType": "State",
      "CountryID": "US"
    },
    "TimeZone": {
      "Code": "PDT",
      "Name": "America/Los_Angeles",
      "GmtOffset": -7.0,
      "IsDaylightSaving": true,
      "NextOffsetChange": "2018-11-04T09:00:00Z"
    },
    "GeoPosition": {
      "Latitude": 47.636,
      "Longitude": -122.327,
      "Elevation": {
        "Metric": {
          "Value": 26.0,
          "Unit": "m",
          "UnitType": 5
        },
        "Imperial": {
          "Value": 85.0,
          "Unit": "ft",
          "UnitType": 0
        }
      }
    },
    "IsAlias": false,
    "ParentCity": {
      "Key": "351409",
      "LocalizedName": "Seattle",
      "EnglishName": "Seattle"
    },
    "SupplementalAdminAreas": [
      {
        "Level": 2,
        "LocalizedName": "King",
        "EnglishName": "King"
      }
    ],
    "DataSets": [
      "Alerts",
      "DailyAirQualityForecast",
      "DailyPollenForecast",
      "ForecastConfidence",
      "MinuteCast"
    ]
  }
]

‘키’ ID는 두 번째 GET 요청에서 사용되므로 유용한 변수입니다. 이 JSON 오브젝트는 URL 뒤에 :save location_info를 지정하여 로컬 변수 location_info에 저장할 수 있습니다.

현재 조건 API 예시

두 번째 connected_content 태그의 경우, 현재 조건 API에 대한 GET 요청이 수행됩니다. 요청 URL에 위치 키를 추가해야 합니다. 여기에 예시 connected_content 태그가 있습니다:

1
{% connected_content http://dataservice.accuweather.com/currentconditions/v1/{{location_info[0].Key}}?apikey={your API key} :save local_weather %}

다음은 반환된 JSON 객체입니다:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[
  {
    "LocalObservationDateTime": "2018-04-10T09:35:00-07:00",
    "EpochTime": 1523378100,
    "WeatherText": "Rain",
    "WeatherIcon": 18,
    "IsDayTime": true,
    "Temperature": {
      "Metric": {
        "Value": 11.0,
        "Unit": "C",
        "UnitType": 17
      },
      "Imperial": {
        "Value": 52.0,
        "Unit": "F",
        "UnitType": 18
      }
    },
    "MobileLink": "http://m.accuweather.com/en/us/seattle-wa/98104/current-weather/41333_pc?lang=en-us",
    "Link": "http://www.accuweather.com/en/us/seattle-wa/98104/current-weather/41333_pc?lang=en-us"
  }
]

connected_content 태그에서 볼 수 있듯이 JSON 오브젝트는 URL 뒤에 :save local_weather를 추가하여 로컬 변수 local_weather에 저장됩니다.

WeatherText의 출력 결과를 {{local_weather[0].WeatherText}}을 참조하여 테스트할 수 있습니다.

API 호출이 {{local_weather[0].WeatherText}}로 응답하고 Rain을 반환하면 사용자는 푸시를 받습니다

이 페이지가 얼마나 도움이 되었나요?
New Stuff!