Kucoin / kucoin-php-sdk

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

Uncaught Swoole\Error: API must be called in the coroutine in #101

Open mkmnstr123 opened 3 years ago

mkmnstr123 commented 3 years ago

Hello,

So I've been trying to execute the order function, but I am getting this error: PHP Fatal error: Uncaught Swoole\Error: API must be called in the coroutine in .../vendor/react/event-loop/src/StreamSelectLoop.php:290

It is weird because I can query the websocket and everything, but not when trying to run this code:

go(function () use ($priceUSDT, $amountUSDTAfterFee) {
                $auth = new Auth('**********', '****', "********", Auth::API_KEY_VERSION_V2);
                $api = new Order($auth, new SwooleHttp);

                go(function () use ($api, $priceUSDT, $amountUSDTAfterFee) {
                    try {
                        $result = $api->create([
                            'clientOid' => uniqid(),
                            'price' => $priceUSDT,
                            'size' => $amountUSDTAfterFee,
                            'symbol' => "{$this->workOnCurrency}-USDT",
                            'type' => 'market',
                            'side' => 'buy',
                        ]);
                        var_dump($result);
                    } catch (\Throwable $e) {
                        var_dump($e->getMessage());
                    }
                });
            });

I did installed the following, as mentioned in the docs:

composer require "kucoin/kucoin-php-sdk:~1.1.0"
pecl install swoole
composer require swlib/saber

Can you guys help pls