php-binance-api.php
public function order(string $side, string $symbol, $quantity, $price, string $type = "LIMIT", array $flags = [], bool $test = false)
    {
        $opt = [
            "symbol" => $symbol,
            "side" => $side,
            "type" => $type,
            "quantity" => $quantity,
            "recvWindow" => 60000,
        ];

        // someone has preformated there 8 decimal point double already
        // dont do anything, leave them do whatever they want
        if (gettype($price) !== "string") {
            // for every other type, lets format it appropriately
            $price = number_format($price, 8, '.', '');
        }

        if (is_numeric($quantity) === false) {
            // WPCS: XSS OK.
            echo "warning: quantity expected numeric got " . gettype($quantity) . PHP_EOL;
        }

        if (is_string($price) === false) {
            // WPCS: XSS OK.
            echo "warning: price expected string got " . gettype($price) . PHP_EOL;
        }

        if ($type === "LIMIT" || $type === "STOP_LOSS_LIMIT" || $type === "TAKE_PROFIT_LIMIT") {
            $opt["price"] = $price;
            $opt["timeInForce"] = "GTC";
        }

        if (isset($flags['stopPrice'])) {
            $opt['stopPrice'] = $flags['stopPrice'];
        }

        if (isset($flags['icebergQty'])) {
            $opt['icebergQty'] = $flags['icebergQty'];
        }

        if (isset($flags['newOrderRespType'])) {
            $opt['newOrderRespType'] = $flags['newOrderRespType'];
        }

        $qstring = ($test === false) ? "v3/order" : "v3/order/test";
        return $this->httpRequest($qstring, "POST", $opt, true);
    }
public function order(string $side, string $symbol, $quantity, $price, string $type = "LIMIT", array $flags = [], bool $test = false)
    {
        $opt = [
            "symbol" => $symbol,
            "side" => $side,
            "type" => $type,
            "quantity" => $quantity,
            "recvWindow" => 60000,
        ];

        // someone has preformated there 8 decimal point double already
        // dont do anything, leave them do whatever they want
        if (gettype($price) !== "string") {
            // for every other type, lets format it appropriately
            $price = number_format($price, 8, '.', '');
        }

        if (is_numeric($quantity) === false) {
            // WPCS: XSS OK.
            echo "warning: quantity expected numeric got " . gettype($quantity) . PHP_EOL;
        }

        if (is_string($price) === false) {
            // WPCS: XSS OK.
            echo "warning: price expected string got " . gettype($price) . PHP_EOL;
        }

        if ($type === "LIMIT" || $type === "STOP_LOSS_LIMIT" || $type === "TAKE_PROFIT_LIMIT") {
            $opt["price"] = $price;
            $opt["timeInForce"] = "GTC";
        }

        if (isset($flags['stopPrice'])) {
            $opt['stopPrice'] = $flags['stopPrice'];
        }

        if (isset($flags['icebergQty'])) {
            $opt['icebergQty'] = $flags['icebergQty'];
        }

        if (isset($flags['newOrderRespType'])) {
            $opt['newOrderRespType'] = $flags['newOrderRespType'];
        }

        $qstring = ($test === false) ? "v3/order" : "v3/order/test";
        return $this->httpRequest($qstring, "POST", $opt, true);
    }
public function order ( string $ side , string $ symbol , $ quantity , $ price , string $ type = "LIMIT" , array $ flags = [ ] , bool $ test = false ) { $ opt = [ "symbol" => $ symbol , "side" => $ side , "type" => $ type , "quantity" => $ quantity , "recvWindow" => 60000 , ] ; // someone has preformated there 8 decimal point double already // dont do anything, leave them do whatever they want if ( gettype ( $ price ) !== "string" ) { // for every other type, lets format it appropriately $ price = number_format ( $ price , 8 , '.' , '' ) ; } if ( is_numeric ( $ quantity ) === false ) { // WPCS: XSS OK. echo "warning: quantity expected numeric got " . gettype ( $ quantity ) . PHP_EOL ; } if ( is_string ( $ price ) === false ) { // WPCS: XSS OK. echo "warning: price expected string got " . gettype ( $ price ) . PHP_EOL ; } if ( $ type === "LIMIT" || $ type === "STOP_LOSS_LIMIT" || $ type === "TAKE_PROFIT_LIMIT" ) { $ opt [ "price" ] = $ price ; $ opt [ "timeInForce" ] = "GTC" ; } if ( isset ( $ flags [ 'stopPrice' ] ) ) { $ opt [ 'stopPrice' ] = $ flags [ 'stopPrice' ] ; } if ( isset ( $ flags [ 'icebergQty' ] ) ) { $ opt [ 'icebergQty' ] = $ flags [ 'icebergQty' ] ; } if ( isset ( $ flags [ 'newOrderRespType' ] ) ) { $ opt [ 'newOrderRespType' ] = $ flags [ 'newOrderRespType' ] ; } $ qstring = ( $ test === false ) ? "v3/order" : "v3/order/test" ; return $ this -> httpRequest ( $ qstring , "POST" , $ opt , true ) ; }
order formats the orders before sending them to the curl wrapper function
You can call this function directly or use the helper functions

@see buy()
@see sell()
@see marketBuy()
@see marketSell() $this->httpRequest( "https://api.binance.com/api/v1/ticker/24hr");

@param $side string typically "BUY" or "SELL"
@param $symbol string to buy or sell
@param $quantity string in the order
@param $price string for the order
@param $type string is determined by the symbol bu typicall LIMIT, STOP_LOSS_LIMIT etc.
@param $flags array additional transaction options
@param $test bool whether to test or not, test only validates the query
@return array containing the response
@throws \Exception
order formats the orders before sending them to the curl wrapper function You can call this function directly or use the helper functions