danieledangeli / betfair-php

Betfair php library
http://danieledangeli.github.io/betfair-php
47 stars 30 forks source link

Get markets ids #14

Closed pedroloureiro82 closed 9 years ago

pedroloureiro82 commented 9 years ago

Hi, how do i get the markets ids from an event? And after i have the market id, how can i get the odds of that market?

danieledangeli commented 9 years ago

Hi @pedrogrou. It's possible to implement this process with the library. Have a look here: https://github.com/danieledangeli/betfair-php/blob/master/examples/SearchMarketBookExample.php where the odds are retrieved given a market Ids object. Each event has more "marketIds". To do that just read this documentation here: https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/listMarketCatalogue and use the proper object in the library: "MarketCatalogue" where you can specify an eventId and get all the marketIds of that event. I have an helper method there: "getMarketCatalogueFilteredByEventIds(array eventIds)" which return the marketCatalogue of the events. In a nutshell: Let's consider your eventId = "1.8913"

$marketCatalogueHelper = $betfair->getMarketCatalogue();
$marketCatalogue = $marketCatalogueHelper->getMarketCatalogueFilteredByEventIds(["1.8913"])
pedroloureiro82 commented 9 years ago

Thank you @danieledangeli.

It worked. Just a small correction in code:

$marketCatalogueHelper = $betfair->getBetfairMarketCatalogue();
$marketCatalogue = $marketCatalogueHelper->getMarketCatalogueFilteredByEventIds(["1.8913"]);

Thank you very much for your work.

danieledangeli commented 9 years ago

:+1: