placeOrders empty reply

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ToroV
    Junior Member
    • Apr 2017
    • 9

    #1

    placeOrders empty reply

    Hi guys, I'm trying to place orders with multiple instructions via php. The problem is that sometimes the call is succesfully executed by betfair, sometimes I got an empty reply
    this is my php code
    PHP Code:
            $obj_data json_encode(
                array(
                    array(
                        
    'jsonrpc' => "2.0"
                        
    'method' => "SportsAPING/v1.0/" $operation
                        
    'params' => json_decode($params)
                        , 
    'id' => 1
                    
    )
                )
            );
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL"https://api.betfair.com/exchange/betting/json-rpc/v1");
            
    curl_setopt($chCURLOPT_POST1);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($chCURLOPT_HTTPHEADER, array(
                
    'X-Application: ' $appKey
                
    'X-Authentication: ' $sessionToken
                
    'Accept-Encoding: gzip, deflate'
                
    'Content-Type: application/json'
                
    'Connection: keep-alive'
            
    ));
            
    curl_setopt($chCURLOPT_CONNECTTIMEOUT60);
            
    curl_setopt($chCURLOPT_TIMEOUT60); //timeout in seconds
            
    curl_setopt($chCURLOPT_ENCODING "gzip");
            
    curl_setopt($chCURLOPT_POSTFIELDS$obj_data);
            
    $res curl_exec($ch);
            if (
    $operation == 'placeOrders') {
                
    error_log('reply from '.$operation.': '.$res);
            }
            
    $reply json_decode($res);
            
    curl_close($ch); 
    $params is this:
    PHP Code:
    stdClass Object
    (                                                      
        [
    marketId] => 1.131280549                          
        
    [customerStrategyRef] => HRS_LAY_FLD               
        
    [instructions] => Array                            
            (                                              
                [
    0] => stdClass Object                     
                    
    (                                      
                        [
    selectionId] => 12139787          
                        
    [handicap] => 0                    
                        
    [side] => LAY                      
                        
    [orderType] => LIMIT               
                        
    [limitOrder] => stdClass Object    
                            
    (                              
                                [
    size] => 6.67             
                                
    [price] => 1.75            
                                
    [persistenceType] => PERSIST
                            
    )                               

                    )

                [
    1] => stdClass Object
                    
    (                 
                        [
    selectionId] => 9987211
                        
    [handicap] => 0         
                        
    [side] => LAY           
                        
    [orderType] => LIMIT    
                        
    [limitOrder] => stdClass Object
                            
    (                          
                                [
    size] => 6.67         
                                
    [price] => 1.75        
                                
    [persistenceType] => PERSIST
                            
    )                               

                    )

            )

        [
    async] =>

    Can you see what is wrong?

    Thank you
  • jabe
    Senior Member
    • Dec 2014
    • 705

    #2
    It's been an age since I last did any PHP. Could you get hold of the output string as it looks prior to sending? That'd allow me to compare it with what my prog (in VB.Net) sends.

    I believe you need "async": true if using async.

    Another thing to be aware of is that if you have a marketId with a zero at the end and treat it like a number, that final zero can get lost, so it's easier to treat things like that as a string. Also the system is happy if things like odds and money amounts arrive with quotes around them.

    Comment

    • ToroV
      Junior Member
      • Apr 2017
      • 9

      #3
      Thank you for your reply Jabe.

      The market id is always passed as string, and the async flag is set to false.

      After a few debug I realized that the empty reply was related to the echo of $reply[0]->result, but the result field is not set in case of error.

      today I'll do some test bets and I'm going to log the full reply, betfair should reply with some error code.

      Comment

      • Fred77
        Junior Member
        • Jan 2009
        • 37

        #4
        If the issue only occurs when you try place multiple bets then your question may be similar to https://forum.bdp.betfair.com/showthread.php?t=3022 relating to http://forum.bdp.betfair.com/showthread.php?t=2900

        Even if that isn't the issue you should still add the "Expect:" header to your curl request so that you don't get bitten later.

        Comment

        • ToroV
          Junior Member
          • Apr 2017
          • 9

          #5
          Hi Fred77,
          I think you've got the case!

          I added the empty Expect header, I'll let you know.

          Thank you very much
          Last edited by ToroV; 01-05-2017, 02:37 PM.

          Comment

          • ToroV
            Junior Member
            • Apr 2017
            • 9

            #6
            Hi Fred77, everything is going fine, the problem was the Expect header. Thank you

            Comment

            Working...
            X