Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Error: Call to undefined method Binance\API::kline() #160

Closed
ahab1b opened this issue Jun 13, 2018 · 3 comments
Closed

Comments

@ahab1b
Copy link

ahab1b commented Jun 13, 2018

I just started using this so I am working through the examples. when I run the following code, I get Fatal error: Uncaught Error: Call to undefined method Binance\API::kline()

Platform:

  • windows

php version:

  • 7.1

code

$api->kline(["BTCUSDT", "EOSBTC"], "5m", function($api, $symbol, $chart) {
    var_dump( $chart );
    //echo "{$symbol} ({$interval}) candlestick update\n";
    $interval = $chart->i;
    $tick = $chart->t;
    $open = $chart->o;
    $high = $chart->h;
    $low = $chart->l;
    $close = $chart->c;
    $volume = $chart->q; // +trades buyVolume assetVolume makerVolume
    echo "{$symbol} price: {$close}\t volume: {$volume}\n";

    $endpoint = strtolower( $symbol ) . '@kline_' . "5m";
    $api->terminate( $endpoint );
});

thank you

@dmzoneill
Copy link
Collaborator

Hey,

I cant reproduce this. Could you please tell me whats happens if you try the following:

Steps

git clone https://github.com/jaggedsoft/php-binance-api.git
cd php-binance-api
composer install
php examples/web_socket_kline.php

You should get this result

dave@dave-laptop:/smb/synology/BinanceBot/crypto/php-binance-api$ php examples/web_socket_kline.php 
/smb/synology/BinanceBot/crypto/php-binance-api/examples/web_socket_kline.php:13:
class stdClass#155 (17) {
  public $t =>
  int(1528910700000)
  public $T =>
  int(1528910999999)
  public $s =>
  string(7) "BTCUSDT"
  public $i =>
  string(2) "5m"
  public $f =>
  int(50944028)
  public $L =>
  int(50944794)
  public $o =>
  string(13) "6254.41000000"
  public $c =>
  string(13) "6263.10000000"
  public $h =>
  string(13) "6267.88000000"
  public $l =>
  string(13) "6247.03000000"
  public $v =>
  string(12) "335.34811000"
  public $n =>
  int(767)
  public $x =>
  bool(false)
  public $q =>
  string(16) "2096235.47317574"
  public $V =>
  string(12) "295.32588800"
  public $Q =>
  string(16) "1846001.89862693"
  public $B =>
  string(1) "0"
}
BTCUSDT price: 6263.10000000	 volume: 2096235.47317574
/smb/synology/BinanceBot/crypto/php-binance-api/examples/web_socket_kline.php:13:
class stdClass#160 (17) {
  public $t =>
  int(1528910700000)
  public $T =>
  int(1528910999999)
  public $s =>
  string(6) "EOSBTC"
  public $i =>
  string(2) "5m"
  public $f =>
  int(18117113)
  public $L =>
  int(18117270)
  public $o =>
  string(10) "0.00151640"
  public $c =>
  string(10) "0.00151810"
  public $h =>
  string(10) "0.00152100"
  public $l =>
  string(10) "0.00151610"
  public $v =>
  string(14) "19320.13000000"
  public $n =>
  int(158)
  public $x =>
  bool(false)
  public $q =>
  string(11) "29.31983351"
  public $V =>
  string(14) "12806.12000000"
  public $Q =>
  string(11) "19.43246997"
  public $B =>
  string(1) "0"
}
EOSBTC price: 0.00151810	 volume: 29.31983351

@ahab1b
Copy link
Author

ahab1b commented Jun 13, 2018

I get other errors, First time I am using git.

`$ C:/php7/php.exe examples/web_socket_kline.php
PHP Fatal error: Uncaught Error: Class 'React\EventLoop\Factory' not found in C :\Binance\php-binance-api\php-binance-api.php:1928
Stack trace:
#0 C:\Binance\php-binance-api\examples\web_socket_kline.php(27): Binance\API->kl ine(Array, '5m', Object(Closure))
#1 {main}
thrown in C:\Binance\php-binance-api\php-binance-api.php on line 1928

Fatal error: Uncaught Error: Class 'React\EventLoop\Factory' not found in C:\Bin ance\php-binance-api\php-binance-api.php:1928
Stack trace:
#0 C:\Binance\php-binance-api\examples\web_socket_kline.php(27): Binance\API->kl ine(Array, '5m', Object(Closure))
#1 {main}
thrown in C:\Binance\php-binance-api\php-binance-api.php on line 1928`

@jaggedsoft
Copy link
Owner

This sounds like an issue with composer. I ran in to the same problem until I managed to get composer installed and working

@ahab1b ahab1b closed this as completed Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants