diff --git a/docs/publish.md b/docs/publish.md index 48d8ca56..fb988ece 100644 --- a/docs/publish.md +++ b/docs/publish.md @@ -163,6 +163,138 @@ a [title](#message-title), and [tag messages](#tags-emojis) 🥳 🎉. Here's an
Urgent notification with tags and title
+You can also do multi-line messages. Here's an example using a click action, a user action, with an external image attachment and forwarded via email: + +=== "Command line (curl)" + ``` sh + #!/bin/bash + curl \ + -H "Click: https://home.nest.com/" \ + -H "Attach: https://nest.com/view/yAxkasd.jpg" \ + -H "Actions: http, Open door, https://api.nest.com/open/yAxkasd, clear=true" \ + -H "Email: phil@example.com" \ + -d "There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell." \ + ntfy.sh/mydoorbell + ``` + +=== "ntfy CLI" + ``` + ntfy publish \ + --click="https://home.nest.com/" \ + --attach="https://nest.com/view/yAxkasd.jpg" \ + --actions="http, Open door, https://api.nest.com/open/yAxkasd, clear=true" \ + --email="phil@example.com" + mydoorbell \ + "There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell." + ``` + +=== "HTTP" + ``` http + POST /mydoorbell HTTP/1.1 + Host: ntfy.sh + Click: https://home.nest.com/ + Attach: https://nest.com/view/yAxkasd.jpg + Actions: http, Open door, https://api.nest.com/open/yAxkasd, clear=true + Email: phil@example.com + + There's someone at the door. 🐶 + + Please check if it's a good boy or a hooman. + Doggies have been known to ring the doorbell. + ``` + +=== "JavaScript" + ``` javascript + fetch('https://ntfy.sh/mydoorbell', { + method: 'POST', // PUT works too + headers: { + 'Click': 'https://home.nest.com/', + 'Attach': 'https://nest.com/view/yAxkasd.jpg', + 'Actions': 'http, Open door, https://api.nest.com/open/yAxkasd, clear=true', + 'Email': 'phil@example.com' + }, + body: `There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell.`, + }) + ``` + +=== "Go" + ``` go + req, _ := http.NewRequest("POST", "https://ntfy.sh/mydoorbell", + strings.NewReader(`There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell.`)) + req.Header.Set("Click", "https://home.nest.com/") + req.Header.Set("Attach", "https://nest.com/view/yAxkasd.jpg") + req.Header.Set("Actions", "http, Open door, https://api.nest.com/open/yAxkasd, clear=true") + req.Header.Set("Email", "phil@example.com") + http.DefaultClient.Do(req) + ``` + +=== "PowerShell" + ``` powershell + $uri = "https://ntfy.sh/mydoorbell" + $headers = @{ Click="https://home.nest.com/" + Attach="https://nest.com/view/yAxkasd.jpg" + Actions="http, Open door, https://api.nest.com/open/yAxkasd, clear=true" + Email="phil@example.com"} + $body = @' +There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell. +'@ + Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -UseBasicParsing + ``` + +=== "Python" + ``` python + requests.post("https://ntfy.sh/mydoorbell", + data="""There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell.""".encode('utf-8'), + headers={ + "Click": "https://home.nest.com/", + "Attach": "https://nest.com/view/yAxkasd.jpg", + "Actions": "http, Open door, https://api.nest.com/open/yAxkasd, clear=true", + "Email": "phil@example.com" + }) + ``` + +=== "PHP" + ``` php-inline + file_get_contents('https://ntfy.sh/mydoorbell', false, stream_context_create([ + 'http' => [ + 'method' => 'POST', // PUT also works + 'header' => + "Content-Type: text/plain\r\n" . + "Click: https://home.nest.com/\r\n" . + "Attach: https://nest.com/view/yAxkasd.jpg\r\n" . + "Actions": "http, Open door, https://api.nest.com/open/yAxkasd, clear=true\r\n" . + "Email": "phil@example.com\r\n" , + 'content' => 'There's someone at the door. 🐶 + +Please check if it's a good boy or a hooman. +Doggies have been known to ring the doorbell.' + ] + ])); + ``` + +
+ ![priority notification](static/img/complete-notification.jpg){ width=500 } +
Notification using a click action, a user action, with an external image attachment and forwarded via email
+
+ ## Message title The notification title is typically set to the topic short URL (e.g. `ntfy.sh/mytopic`). To override the title, you can set the `X-Title` header (or any of its aliases: `Title`, `ti`, or `t`). diff --git a/docs/static/img/complete-notification.jpg b/docs/static/img/complete-notification.jpg new file mode 100644 index 00000000..f6ed6612 Binary files /dev/null and b/docs/static/img/complete-notification.jpg differ