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

access websocket server finance data #42

Open
blackcatt opened this issue Nov 20, 2022 · 1 comment
Open

access websocket server finance data #42

blackcatt opened this issue Nov 20, 2022 · 1 comment

Comments

@blackcatt
Copy link

Help solve the problem. I need to access the binance websocket data, but I don't see a method to do this.
Am I bad at searching?
Or should I implement this method myself by modifying Mr. zhouaini's source code?
something like this:

$binance=new BinanceWebSocket();
$binance->config([ ... ]);
$binance->onMessage(
  function($data){
    // my busines logic
  }
);
$binance->start();
@zhouaini528
Copy link
Owner

zhouaini528 commented Nov 21, 2022

Help solve the problem. I need to access the binance websocket data, but I don't see a method to do this. Am I bad at searching? Or should I implement this method myself by modifying Mr. zhouaini's source code? something like this:

$binance=new BinanceWebSocket();
$binance->config([ ... ]);
$binance->onMessage(
  function($data){
    // my busines logic
  }
);
$binance->start();

This mode is not supported temporarily because it is highly encapsulated. You can view the source code.

$binance->onMessage(
	function($data){
	// my busines logic
	}
);

https://github.com/zhouaini528/binance-php/blob/master/src/Api/WebSocket/SocketServer.php#L102

You can modify the source code to see if it is the result you need.

function onMessage($global){
    return function($con,$data) use($global){
    	//Here are all the data returned by the exchange
        $data=json_decode($data,true);
        print_r($data);
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants