I\'m trying to send a fire-and-forget request from PHP to my websocket aws api gateway.
I\'ve set up an action called \"sendmessage\".
This is the code I\'m
You need to use PHP websocket client for your requirement. Below is one of the client which can be used for your requirements:
https://github.com/paragi/PHP-websocket-client
Sample 1:
if( $sp = websocket_open('echo.websocket.org',80) ) {
websocket_write($sp,"hello server");
echo "Server responed with: " . websocket_read($sp,$errstr);
}
Sample 2:
$headers = ["Cookie: SID=".session_id()];
$sp = websocket_open('echo.websocket.org',80,$headers,$errstr,16);
if($sp){
$bytes_written = websocket_write($sp,"hello server");
if($bytes_written){
$data = websocket_read($sp,$errstr);
echo "Server responed with: " . $errstr ? $errstr : $data;
}
}
Hope this helps.