tf-redfree / PHP-btce-api

BTC-e API Class
MIT License
44 stars 41 forks source link

invalid nonce parameter; #10

Open danyoborg opened 7 years ago

danyoborg commented 7 years ago

I keep getting the following message (or something very similar)

API Error Message: invalid nonce parameter; on key:1499873709, you sent:'1499873709', you should send:1499873710. Response: Array ( [success] => 0 [error] => invalid nonce parameter; on key:1499873709, you sent:'1499873709', you should send:1499873710 )

Is this a known issue? and is there a simple fix?

Thanks

tf-redfree commented 7 years ago

Hi Danyoborg,

This is not a known issue, would you be able to show me the code from your use case? I might be able to help debug what is going wrong, or work out a fix if there is something wrong with the library.

Cheers, Tony

danyoborg commented 7 years ago

Hi Tony,

Thanks for replying, here is my code:

require_once('btce-api.php');
$BTCeAPI = new BTCeAPI($getkey, $getsecret);
try {
    $orders_active = $BTCeAPI->apiQuery('ActiveOrders');

    //loop through data here

} catch(BTCeAPIException $e) {
    echo $e->getMessage();
}

I simple then fetch this via an ajax call and loop through the data, which refreshes every 5 seconds.

Please let me know if you need anything else?

Thanks

tf-redfree commented 7 years ago

Hi danyoborg

I think I maybe able to see the problem,

Using the message provided: invalid nonce parameter; on key:1499873709, you sent:'1499873709', you should send:1499873710

Comparing this error to my regex: /:([0-9]+),/' This is probably matching the 'on key' section rather than the you should send section.

There is a trigger error as part of this which WARNs but does not throw an exception could you confirm you get an output like this:

Code Issues 1 Pull requests 0 Pulse btce-api.php

<?php /**

If these numbers are the same (i.e. What we sent versus what this error says is the server nonce) I would suspect the error message has been changed by BTC-e and I will code up a fix for the library.

Cheers, Tony

tf-redfree commented 7 years ago

I copied the full string I apologise I am on a phone:

An error like this:

Nonce we sent 12345 is invalid, retrying request with server returned nonce: 12345 If these numbers are the same (i.e. What we sent versus what this error says is the server nonce)

I would suspect the error message has been changed by BTC-e and I will code up a fix for the library. Cheers, Tony

tf-redfree commented 7 years ago

Hi danyoborg,

Could you please use the branch "nonce-test" to test the functional change for your use case.

In the cloned repository: "git fetch --all; git checkout nonce-test" I have updated the nonce checker to look at the server returned value based upon the string which came back in the error code.

If this fixes it for you, I will update the master branch with these changes.

Cheers, Tony