<?php $argv[1] = ""; $argv[2] = ""; $APP_KEY = $argv[1]; $SESSION_TOKEN = $argv[2]; $DEBUG = False; // Setting DEBUG to true will output all request / responses to api-ng echo "1. Get all Event Types....<br>"; $allEventTypes = getAllEventTypes($APP_KEY, $SESSION_TOKEN); echo "<br>2. Extract Event Type Id for Horse Racing....<br>"; $horseRacingEventTypeId = extractHorseRacingEventTypeId($allEventTypes); echo "<br>3. EventTypeId for Horse Racing is: $horseRacingEventTypeId <br>"; echo "<br>4. Get next horse racing market in the UK....<br>"; $nextHorseRacingMarket = getNextUkHorseRacingMarket($APP_KEY, $SESSION_TOKEN, $horseRacingEventTypeId); echo "<br>5. Print static marketId, name and runners....<br>"; printMarketIdAndRunners($nextHorseRacingMarket); function getAllEventTypes($appKey, $sessionToken) { $jsonResponse = sportsApingRequest($appKey, $sessionToken, 'listEventTypes', '{"filter":{}}'); return $jsonResponse[0]->result; } function extractHorseRacingEventTypeId($allEventTypes) { foreach ($allEventTypes as $eventType) { if ($eventType->eventType->name == 'Soccer') { return $eventType->eventType->id; } } } function getNextUkHorseRacingMarket($appKey, $sessionToken, $horseRacingEventTypeId) { $params = '{"filter": { "eventTypeIds": ["' . $horseRacingEventTypeId . '"], "marketStartTime":{"from":"' . date('c') . '"}}, "maxResults": "200", "marketProjection": ["RUNNER_DESCRIPTION"] }'; $jsonResponse = sportsApingRequest($appKey, $sessionToken, 'listMarketCatalogue', $params); return $jsonResponse[0]->result[0]; } ?>
... явился следующий результат:
2. Extract Event Type Id for Horse Racing....
3. EventTypeId for Horse Racing is: 1
4. Get next horse racing market in the UK....
5. Print static marketId, name and runners....
MarketId: 1.124002994
MarketName: Half Time Score
SelectionId: 1 RunnerName: 0 - 0
SelectionId: 3 RunnerName: 1 - 1
SelectionId: 7 RunnerName: 2 - 2
SelectionId: 2 RunnerName: 1 - 0
SelectionId: 5 RunnerName: 2 - 0
SelectionId: 6 RunnerName: 2 - 1
SelectionId: 4 RunnerName: 0 - 1
SelectionId: 9 RunnerName: 0 - 2
SelectionId: 8 RunnerName: 1 - 2
SelectionId: 4506345 RunnerName: Any Unquoted
Возникает вопрос: почему отображается только один рынок, а не все существующие?