php – Kraken.com API – Adding more pairs to Ticker array-ThrowExceptions

Exception or error:

I’m trying to add multiple pairs to the array below but I can only retrieve the last pair. So how can I get both pairs / add more pairs?

$ticker = $kraken->QueryPublic('Ticker', array('pair' => 'XXBTZEUR', 'pair' => 'XXRPXXBT'));

print "<pre>";
print_r($ticker);
print "</pre>";

Result:

Notice: Undefined index: XXBTZEUR in /home/… on line 14

Array

(
    [error] => Array
        (
        )

    [result] => Array
        (
            [XXRPXXBT] => Array
                (
                    [a] => Array
                        (
                            [0] => 0.000028120
                            [1] => 10836
                            [2] => 10836.000
                        )
How to solve:

You are using this associated array:

array('pair' => 'XXBTZEUR', 'pair' => 'XXRPXXBT')

An associated array is a set of key-value pairs. The key identifies the value. Since your key of pair is duplicate here, the latter abrogates the former. You will probably need to do as many queries as the number of pairs you need to work with.

Leave a Reply

Your email address will not be published. Required fields are marked *