File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use ApiClients \Client \Pusher \Event ;
4
+ use React \EventLoop \Factory ;
5
+ use Rx \Observer \CallbackObserver ;
6
+ use ApiClients \Client \Pusher \AsyncClient ;
7
+
8
+ require dirname (__DIR__ ) . DIRECTORY_SEPARATOR . 'vendor/autoload.php ' ;
9
+
10
+ $ loop = Factory::create ();
11
+
12
+ /**
13
+ * The App ID isn't a secret and comes from the bitstamp docs:
14
+ * @link https://www.bitstamp.net/websocket/
15
+ */
16
+ $ client = new AsyncClient ($ loop , 'de504dc5763aeef9ff52 ' );
17
+
18
+ $ channelitems = array ('live_trades ' ,'live_trades_xrpusd ' );
19
+ foreach ($ channelitems as $ channelitem ) {
20
+ $ client ->channel ($ channelitem )->subscribe (new CallbackObserver (function (Event $ event ) {
21
+ echo 'Channel: ' . $ event ->getChannel (). PHP_EOL ;
22
+ echo 'Event: ' . $ event ->getEvent (). PHP_EOL ;
23
+ echo 'Data: ' . print_r ($ event ->getData (),1 ). PHP_EOL ;
24
+ }));
25
+ }
26
+
27
+ $ loop ->run ();
You can’t perform that action at this time.
0 commit comments