简体   繁体   中英

How get info from WebSocket using php?

I want get last transaction from blockchain.info On this site has API Websocket. But i can use API Websocket only for JavaScript. I can get last transaction using this code

<script type="text/javascript">
    var conn = new WebSocket('ws://ws.blockchain.info/inv');
      conn.onopen = function () {
        console.log('open');
        conn.send('{"op":"unconfirmed_sub"}');
      }
      conn.onclose = function () {
        console.log('close');
      }
      conn.onerror = function (error) {
        console.log('websocket error: ' + error);
      }
      conn.onmessage = function (e) {
        console.log(e);
      }
    </script>

But i need get info above using php and after save in mysql. How can I get it through php?

Thank you in advance!

I found a library that solves the problem it phpws

Thanks to all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM