Is there a limit with placeOrder using PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Baby Jesus
    Junior Member
    • Apr 2009
    • 7

    #1

    Is there a limit with placeOrder using PHP?

    Come across some annoying quirk where the API isn't letting me send more than 6 bets in a single request for some unknown reason. I'm using PHP and tweaked the sample code off the site. Can anyone think of a reason why the requests with over 6 bets are being rejected, unfortunately the API is only giving a response of null from the sample php code.

    I'm just using the code below to submit the bets.

    $jsonResponse = sportsApingRequest($appKey,$sessionToken, 'placeOrders/', $params);

    $params of
    {"marketId":"1.121637352","instructions":[{"selectionId":10343384,"handicap":"0","side":"LAY ","orderType":"LIMIT","limitOrder":{"size":"50","p rice":"2","persistenceType":"MARKET_ON_CLOSE"}},{" selectionId":10485442,"handicap":"0","side":"LAY", "orderType":"LIMIT","limitOrder":{"size":"50","pri ce":"2","persistenceType":"MARKET_ON_CLOSE"}},{"se lectionId":6163562,"handicap":"0","side":"LAY","or derType":"LIMIT","limitOrder":{"size":"50","price" :"2","persistenceType":"MARKET_ON_CLOSE"}},{"selec tionId":10485441,"handicap":"0","side":"LAY","orde rType":"LIMIT","limitOrder":{"size":"50","price":" 2","persistenceType":"MARKET_ON_CLOSE"}},{"selecti onId":10351841,"handicap":"0","side":"LAY","orderT ype":"LIMIT","limitOrder":{"size":"50","price":"2" ,"persistenceType":"MARKET_ON_CLOSE"}},{"selection Id":10277121,"handicap":"0","side":"LAY","orderTyp e":"LIMIT","limitOrder":{"size":"50","price":"2"," persistenceType":"MARKET_ON_CLOSE"}}]}
    Will happily go thru , whereas the following just gives a response as Call to api-ng failed: Response: null

    {"marketId":"1.121637352","instructions":[{"selectionId":10343384,"handicap":"0","side":"LAY ","orderType":"LIMIT","limitOrder":{"size":"50","p rice":"2","persistenceType":"MARKET_ON_CLOSE"}},{" selectionId":10485442,"handicap":"0","side":"LAY", "orderType":"LIMIT","limitOrder":{"size":"50","pri ce":"2","persistenceType":"MARKET_ON_CLOSE"}},{"se lectionId":6163562,"handicap":"0","side":"LAY","or derType":"LIMIT","limitOrder":{"size":"50","price" :"2","persistenceType":"MARKET_ON_CLOSE"}},{"selec tionId":10485441,"handicap":"0","side":"LAY","orde rType":"LIMIT","limitOrder":{"size":"50","price":" 2","persistenceType":"MARKET_ON_CLOSE"}},{"selecti onId":10351841,"handicap":"0","side":"LAY","orderT ype":"LIMIT","limitOrder":{"size":"50","price":"2" ,"persistenceType":"MARKET_ON_CLOSE"}},{"selection Id":10277121,"handicap":"0","side":"LAY","orderTyp e":"LIMIT","limitOrder":{"size":"50","price":"2"," persistenceType":"MARKET_ON_CLOSE"}},{"selectionId ":10485440,"handicap":"0","side":"LAY","orderType" :"LIMIT","limitOrder":{"size":"50","price":"2","pe rsistenceType":"MARKET_ON_CLOSE"}}]}
    Got me stumped so any help or workarounds in php would be appreciated, thanks.
  • Baby Jesus
    Junior Member
    • Apr 2009
    • 7

    #2
    Guess there aren't many php users or any come across the same problem

    I've sorted the limitation for now just by using array_chunk to split the array into chunks of six and place the orders like that. Works fine so it'll have to do for now.

    PHP Code:
    $data=array_chunk($instructions6);

    foreach(
    $data as $instructions){

    $params = new stdClass;
    $params->marketId $marketId;
    $params->instructions $instructions;

    $params=json_encode($params);

    $jsonResponse sportsApingRequest($appKey,$sessionToken'placeOrders/'$params);  


    Comment

    • Fred77
      Junior Member
      • Jan 2009
      • 37

      #3
      The sample code is just a sample, you need to pad it out with more error detection and handling, as there's definitely something other than "null" going on.

      It's probably caused by this http://forum.bdp.betfair.com/showthread.php?t=2900

      Curl's default behaviour is to use Expect:100-continue when the posted data is over a certain size, hence your problem.

      If so then it's an easy fix

      PHP Code:
          curl_setopt($chCURLOPT_HTTPHEADER, array(
              
      'Expect:'// disable Expect:100-continue behaviour
              
      'X-Application: ' $appKey,
              
      'X-Authentication: ' $sessionToken,
              
      'Accept: application/json',
              
      'Content-Type: application/json'
          
      )); 

      Comment

      • Baby Jesus
        Junior Member
        • Apr 2009
        • 7

        #4
        Thanks Fred, that's sorted it out.

        Comment

        Working...
        X