socketio / socket.io-protocol

Socket.IO Protocol specification
https://socket.io
507 stars 62 forks source link

Is there any rule to escape when sending a JSON via cURL? #28

Closed El-Tommy closed 1 year ago

El-Tommy commented 1 year ago

My application is in PHP, and due to the lack of clients for SocketIO with support for V4.0 I am creating internal functions that connect via cURL to emit events from my application to the Socket.IO server that I have.

So far everything is going fine, when I just need to set the server event name and a basic sent value. Like the example below:

CURLOPT_POSTFIELDS => '42["eventNameOnServer","My Value."]'

My problem is occurring when I try to send a JSON, such as {"id":1,"value":"String"}.

CURLOPT_POSTFIELDS => '42["eventNameOnServer","{\\"id\\":1,\\"value\\":\\"String\\"}."]'

For double quotes I realized that I have to always put two \ in front of the quote to be accepted by SocketIO. Are there any other rules that must be followed when performing this procedure?