Skip to content

Commit b42dfd3

Browse files
authored
Merge pull request #4 from Darkflib/master
Added bitstamp example
2 parents 0418749 + 795c668 commit b42dfd3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/bitstamp-async.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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();

0 commit comments

Comments
 (0)