danieledangeli / betfair-php

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

Place bets #12

Closed acegilz closed 8 years ago

acegilz commented 9 years ago

What is the simpler way to place and remove bets on betfair via api?

danieledangeli commented 9 years ago

Hi, It will be available soon!

acegilz commented 9 years ago

While you don't have the helper completed, you can update the README with this that will surelly be helpfull and save some hours to some people like me:

public function placebetfair($marketId, $side, $selectionId, $size, $price)
{

    $betfair = BetfairFactory::createBetfair('appkey', 'user', 'pass');

    $params = Param::create();
    $params->marketId = $marketId;
    $params->instructions = [['selectionId' => $selectionId, 'side' => $side, 'orderType' => 'LIMIT', 'limitOrder' => ['size' => $size, 'price' => $price, 'persistenceType' =>'LAPSE']]];
    $params->customerRef = 'fdsdf';

    $placeOrders = $betfair->api($params, 'placeOrders');

}
danieledangeli commented 9 years ago

Hey @acegilz, why not make a PR? Just rename placebetfair to placeOrder or placeBetfair in camelCase. If you want edit the readme, so you will became a contributor as well

ozer85 commented 8 years ago

Hi @acegilz, I'm trying to do exactly the same thing here - place an order into the market - and getting the same error you were in this thread: "Undefined index: result in ...ArrayRpcAdapter.php on line 17". Did you work out what was causing it? I tried using the code above (with the exception that I passed in the $betfair object as an argument) but am still getting the error with no bets being executed. Any help much appreciated!

danieledangeli commented 8 years ago

Hey @ozer85 , I think that this PR can be related on this error: https://github.com/danieledangeli/betfair-php/pull/19 I'm happy to merge it in right now

danieledangeli commented 8 years ago

If you guys are using a different version, probably you can your your own adapter to understand what is going on. If you decide to use the master version, now with that PR a Betfair error will be returned. When I'll have more time I'd like to raise proper exceptions!

ozer85 commented 8 years ago

Thanks @danieledangeli, that makes sense. And thanks for the awesome library too.