Kucoin / kucoin-php-sdk

PHP SDK for KuCoin API.
https://docs.kucoin.com
MIT License
79 stars 41 forks source link

Class 'Kucoin\SDK\Auth' not found #106

Closed inazeem closed 3 years ago

inazeem commented 3 years ago

I am trying api with laravel and i am getting the auth not found error. I have checked the directory and file is there. I am not sure why it is not picking up. Any help will be great.

$auth = new Auth($this->api_key, $this->api_secret, $this->passphrase, Auth::API_KEY_VERSION_V2);

hhxsv5 commented 3 years ago

Did you forget to use namespace use KuCoin\SDK\Auth;? Or try composer dumpautoload

inazeem commented 3 years ago

namespace App\Http\Controllers;

use Illuminate\Http\Request; use KuCoin\SDK\PublicApi\Time; use KuCoin\SDK\PrivateApi\Account; use KuCoin\SDK\Exceptions\HttpException; use KuCoin\SDK\Exceptions\BusinessException; use Kucoin\SDK\Auth;

class kucoinController extends Controller { //removed the keys for security.

public function index(){

    // Auth version v2 (recommend)
    $auth = new Auth($this->api_key, $this->api_secret, $this->passphrase, Auth::API_KEY_VERSION_V2);
    // Auth version v1
     //$auth = new Auth('key', 'secret', 'passphrase');

    $api = new Account($auth);

    try {
        $result = $api->getList(['type' => 'main']);
        var_dump($result);
    } catch (HttpException $e) {
        var_dump($e->getMessage());
    } catch (BusinessException $e) {
        var_dump($e->getMessage());
    }
}

}

So this is what I have on top of the controller class.

hhxsv5 commented 3 years ago

There is a typo 'Kucoin', it should be 'KuCoin'.

inazeem commented 3 years ago

Thanks, It worked!