cryptopia-api-php icon indicating copy to clipboard operation
cryptopia-api-php copied to clipboard

Can't Connect to Cryptopia, Error:

Open plogic opened this issue 8 years ago • 8 comments

Dear KittyCatTech,

Although i am a real beginner your code in cryptopia-api-php looked clear to me. But using it will every time come with an "Can't Connect to Cryptopia, Error: ". (No real error is written out.) Does it have something to do with the API problem? You wrote : "There is a bug in the API if you send no parameters it will return Success:true Error: Market not found." How can this be handeld? Did you find a solution already?

With regards, Paul van den Elsaker

plogic avatar Apr 23 '17 20:04 plogic

I am getting this same error. I have not found a solution as of yet either.

iansmellis avatar May 19 '17 13:05 iansmellis

It is because of the way nonce is calculated, the api cannot make more than one call per second. The api is already making a call in constructor to get balance, so any other call is failing. Just update constructor to:

public function __construct($priv, $pub) {
      $this->privateKey = $priv;
      $this->publicKey = $pub;    
   }

dexter369 avatar May 19 '17 20:05 dexter369

That is already in this https://github.com/KittyCatTech/cryptopia-api-php/blob/master/cryptopiaAPI.php is that what you are taling about?

iansmellis avatar May 20 '17 03:05 iansmellis

Yes replace __construct there with above.

dexter369 avatar May 20 '17 15:05 dexter369

I am not sure what you are trying to tell me, That is already there

public function __construct($priv, $pub) { $this->privateKey = $priv; $this->publicKey = $pub; $result = json_decode($this->apiCall("GetBalance", array( 'Currency'=> 'BTC' )), true); // There is a bug in the API if you send no parameters it will return Success:true Error: Market not found. // Array // ( // [Success] => 1 // [Message] => // [Data] => // [Error] => Market not found. // ) // print_r($result); if( $result['Success'] != "true" ) { throw new Exception("Can't Connect to Cryptopia, Error: " . $result['Error'] ); return false; } return true; }

iansmellis avatar May 20 '17 17:05 iansmellis

simply replace the whole thing you pasted above with:

public function __construct($priv, $pub) {
      $this->privateKey = $priv;
      $this->publicKey = $pub;    
   }

you dont lose anything by deleting unnecessary code.

dexter369 avatar May 20 '17 21:05 dexter369

Thank you for helping me. That worked perfectly!

I really appreciate it!

iansmellis avatar May 20 '17 21:05 iansmellis

i'm sorry but i'm a real noob, i don't know what i have to do with the code. What I have to do with exactly?

valala avatar Jul 20 '17 11:07 valala