C
C
celovec2019-07-22 10:34:48
PHP
celovec, 2019-07-22 10:34:48

How to send data to Node.JS socket.io using php?

A GET comes to the server, /api.php?id=2342342&console=test
How can I call the socket server in api.php so that it sends everything that came to the console
socket.emit('chat message', $_GET['console'] );
js to api.php is not processed. You need to contact the socket server using php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Dergachov, 2019-07-22
@vanillathunder

Send a curl request

$qry_str = "id=2342342&console=test";
$ch = curl_init();

// Set query data here with the URL
curl_setopt($ch, CURLOPT_URL, 'http://example.com/test' . $qry_str); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$content = trim(curl_exec($ch));
curl_close($ch);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question