PieSocket logo

Publish with Shell

Use the following code snippets to publish a message on a WebSocket channel with curl or wget.

Using curl

# Demo API key and secret used, get yours at https://piesocket.com

curl --location --request POST 'https://www.piesocket.com/api/publish' \
--header 'Content-Type: application/json' \
--data-raw '{
    "key": "oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm",
    "secret": "d8129f82f8dd71910aa4a7efa30a7297",
    "channelId": 1,
    "message": "Hello world!"
}'

Using wget

# Demo API key and secret used, get yours at https://piesocket.com

wget --no-check-certificate --quiet \
  --method POST \
  --timeout=0 \
  --header 'Content-Type: application/json' \
  --body-data '{
    "key": "oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm",
    "secret": "d8129f82f8dd71910aa4a7efa30a7297",
    "channelId": 1,
    "message": "Hello world!"
}' \
   'https://www.piesocket.com/api/publish'

This sends a JSON message to channel 1.

Please note that this example uses a demo key and secret which is public. The demo key is only for quick testing purpose and you should not use this in your application.

You can get your free API key and API secret here.

Help

Facing difficulties? Use the chat box on the bottom-right corner of this page to reach us.