Я использую Node.js
написать свое приложение Google AdWords.
API Google AdWords: v201809
.
Вот мой случай:
Я получаю xml
данные GEO_PERFORMANCE_REPORT
, например:
<row campaignID='1733539359' campaign='Campaign Name3.0-119-1552463540147' impressions='1' countryTerritory='2818' city='1005392'/>
<row campaignID='1733539359' campaign='Campaign Name3.0-119-1552463540147' impressions='4' countryTerritory='2716' city='1028774'/>
Как видите, есть два поля с именами: countryTerritory
и city
.
Это countrycriteriaid и citycriteriaid
Теперь я хочу получить название страны и название города. Это можно сделать с помощью LocationCriterionService
Вот мой фрагмент кода для selector
:
const criterionIds = [2818, 2716, 1005392, 1028774];
const selector = new AdWords.Selector.model({
fields: ['CanonicalName', 'Reach'],
predicates: [ {
field: 'Id',
operator: 'IN',
values: criterionIds
}],
ordering: []
})
И я получаю ответ:
{
"entries": [
{
"location": {
"id": "2716",
"Criterion.Type": "Location",
"locationName": "Zimbabwe",
"displayType": "Country",
"targetingStatus": "ACTIVE"
},
"canonicalName": "Zimbabwe",
"reach": "736000"
},
{
"location": {
"id": "2818",
"Criterion.Type": "Location",
"locationName": "Egypt",
"displayType": "Country",
"targetingStatus": "ACTIVE"
},
"canonicalName": "Egypt",
"reach": "20300000"
},
{
"location": {
"id": "1005392",
"Criterion.Type": "Location",
"locationName": "Damietta",
"displayType": "City",
"targetingStatus": "ACTIVE",
"parentLocations": [
{
"id": "21479",
"Criterion.Type": "Location",
"locationName": "Damietta Governorate",
"displayType": "Governorate",
"targetingStatus": "ACTIVE"
},
{
"id": "2818",
"Criterion.Type": "Location",
"locationName": "Egypt",
"displayType": "Country",
"targetingStatus": "ACTIVE"
}
]
},
"canonicalName": "Damietta,Damietta Governorate,Egypt",
"reach": "593000"
},
{
"location": {
"id": "1028774",
"Criterion.Type": "Location",
"locationName": "Harare",
"displayType": "City",
"targetingStatus": "ACTIVE",
"parentLocations": [
{
"id": "9070024",
"Criterion.Type": "Location",
"locationName": "Harare Province",
"displayType": "Province",
"targetingStatus": "ACTIVE"
},
{
"id": "2716",
"Criterion.Type": "Location",
"locationName": "Zimbabwe",
"displayType": "Country",
"targetingStatus": "ACTIVE"
}
]
},
"canonicalName": "Harare,Harare Province,Zimbabwe",
"reach": "593000"
}
]
}
Надеюсь, это поможет.