'Setting websocket for GATE.IO

I have configured websocket for Binance. The server receives any price change in the pair. How do I implement a similar for Gate.io?

<?php

$sock = stream_socket_client("tls://stream.binance.com:9443",$error,$errnum,30,STREAM_CLIENT_CONNECT,stream_context_create(null));
if(!$sock) {
    
    echo "[$errnum] $error" . PHP_EOL;
    
}else{
    
    fwrite($sock, "GET /stream?streams=ethbusd@bookTicker HTTP/1.1\r\nHost: stream.binance.com:9443\r\nAccept: */*\r\nConnection: Upgrade\r\nUpgrade: websocket\r\nSec-WebSocket-Version: 13\r\nSec-WebSocket-Key: ".rand(0,999)."\r\n\r\n");
    while (!feof($sock)) {

        $string = fgets($sock, 1024);       
        var_dump($string);  
    
    }

}

I'm inserting this link - wss://api.gateio.ws/ws/v4/, but I can't set up a stream



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source