Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
Sportradar
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
잉글랜드 프리미어 리그 경기 목록 검색
/**
* @fileoverview Example of using Sportsradar API to get English Premier League
* soccer schedules, to use in adjusting campaigns.
* The principles of this example could easily be reused against any of the
* sports feeds available from Sportradar.
*
* Example: Get fixtures on 1st Oct 2016
* const schedule = getSoccerSchedule(2016, 10, 1);
* See https://developers.google.com/google-ads/scripts/docs/features/third-party-apis#working_with_api_responses
* See https://developer.sportradar.com/
*/
// Replace with the API Key found on your Sportradar API Application page.
const API_KEY = 'ENTER_API_KEY';
// Insert your email address here for notification of API request failures.
const EMAIL_ADDRESS = 'ENTER_EMAIL_ADDRESS';
const VERSION = 4;
const LEAGUE = 'en';
// Set to false when no longer in trial mode.
const TRIAL_MODE = true;
/**
* Retrieves a list of fixtures from the Soccer Schedule API.
* @param {number} year The year for which to get matches, in the form yyyy.
* @param {number} month The month for which to get matches, in range 1-12.
* @param {number} day The day for which to get matches, in range 1-31.
* @return {!Array.<!Object>} An array of object containing fixture info or
* null if the request was unsuccessful.
*/
function getSoccerSchedule(year, month, day) {
const urlTemplate =
'https://api.sportradar.com/soccer/%s/v%d/%s/schedules/%d-%02d-%02d/schedules.xml';
const accessLevel = TRIAL_MODE ? 'trial' : 'production';
const url = Utilities.formatString(
urlTemplate, accessLevel, VERSION, LEAGUE, year, month, day);
const response = UrlFetchApp.fetch(url, {
headers: {
'x-api-key': API_KEY
}
});
return parseScheduleXml(response.getContentText());
}
/**
* Converts the date format returned from the XML feed into a Date object.
* @param {string} scheduleDate A date from the feed e.g. 2016-07-11T17:00:00Z
* @return {!Date} The resulting Date object.
*/
function parseScheduleDate(scheduleDate) {
return new Date(
scheduleDate.replace(/-/g, '/').replace('T', ' ').replace('Z', ' GMT'));
}
/**
* Parses the schedule XML, identifying only English Premier League Soccer
* matches, as an example of selecting events on which to make Google Ads
* changes.
* @param {string} xmlText XML response body from a call to the soccer schedule
* API.
* @return {!Array.<!Object>} An array of object containing fixture info.
*/
function parseScheduleXml(xmlText) {
const fixtures = [];
const rootElement = XmlService.parse(xmlText).getRootElement();
// The namespace is required for accessing child elements in the schema.
const namespace = rootElement.getNamespace();
const scheduleElement = rootElement.getChild('schedule', namespace);
if (!scheduleElement) {
return fixtures;
}
const sportEventElements = scheduleElement.getChildren('sport_event', namespace);
for (let i = 0; i < sportEventElements.length; i++) {
const sportEventElement = sportEventElements[i];
const scheduled = sportEventElement.getAttribute('start_time').getValue();
const scheduledDate = parseScheduleDate(scheduled);
const contextElement = sportEventElement.getChild('sport_event_context', namespace);
const categoryElement = contextElement.getChild('category', namespace);
const country = categoryElement.getAttribute('name').getValue();
const competitionElement = contextElement.getChild('competition', namespace);
const tournamentName = competitionElement.getAttribute('name').getValue();
if (tournamentName === 'Premier League' && country === 'England') {
const competitorsElement = sportEventElement.getChild('competitors', namespace);
const competitorElements = competitorsElement.getChildren('competitor', namespace);
let homeTeamName = '';
let awayTeamName = '';
for (let j = 0; j < competitorElements.length; j++) {
const competitorElement = competitorElements[j];
const qualifier = competitorElement.getAttribute('qualifier').getValue();
const teamName = competitorElement.getAttribute('name').getValue();
if (qualifier === 'home') {
homeTeamName = teamName;
} else if (qualifier === 'away') {
awayTeamName = teamName;
}
}
fixtures.push({
date: scheduledDate,
homeTeam: homeTeamName,
awayTeam: awayTeamName
});
}
}
return fixtures;
}
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2026-07-15(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2026-07-15(UTC)"],[],[]]