Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contentsindent10px 


The sample code is intended to demonstrate how you can utilise PHP to call the operations within API-NG and extract the desired output, it is very much a cut down sample and is not intended to be used in a production environment.


In a Debian linux distro you can use the following commands to install the pre-requisites:

sudo apt-get update
sudo apt-get install php5-cli
sudo apt-get install php5-curl

Run the scripts




php -f jsonrpc.php <appkey> <sessiontoken>

Rescript →  

php -f rescript.php <appkey> <sessiontoken>

Code Snippets

Calling API-NG with JSON-RPC protocol


Code Block
printBetResult(placeBet($appKey, $sessionToken, $marketId, $selectionId));

function placeBet($appKey, $sessionToken, $marketId, $selectionId)

    $params = '{"marketId":"' . $marketId . '",
                     [{"selectionId":"' . $selectionId . '",
                       }], "customerRef":"fsdf"}';

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

    return $jsonResponse;


function printBetResult($betResult)
    echo "Status: " . $betResult->status;

    if ($betResult->status == 'FAILURE') {
        echo "\nErrorCode: " . $betResult->errorCode;
        echo "\n\nInstruction Status: " . $betResult->instructionReports[0]->status;
        echo "\nInstruction ErrorCode: " . $betResult->instructionReports[0]->errorCode;
    } else
        echo "Warning!!! Bet placement succeeded !!!";

Table of Contents