mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-11-26 21:25:18 +01:00
commit
ea30132763
2 changed files with 132 additions and 0 deletions
132
docs/publish.md
132
docs/publish.md
|
@ -163,6 +163,138 @@ a [title](#message-title), and [tag messages](#tags-emojis) 🥳 🎉. Here's an
|
||||||
<figcaption>Urgent notification with tags and title</figcaption>
|
<figcaption>Urgent notification with tags and title</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
|
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.'
|
||||||
|
]
|
||||||
|
]));
|
||||||
|
```
|
||||||
|
|
||||||
|
<figure markdown>
|
||||||
|
![priority notification](static/img/complete-notification.jpg){ width=500 }
|
||||||
|
<figcaption>Notification using a click action, a user action, with an external image attachment and forwarded via email</figcaption>
|
||||||
|
</figure>
|
||||||
|
|
||||||
## Message title
|
## Message title
|
||||||
The notification title is typically set to the topic short URL (e.g. `ntfy.sh/mytopic`). To override the 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`).
|
you can set the `X-Title` header (or any of its aliases: `Title`, `ti`, or `t`).
|
||||||
|
|
BIN
docs/static/img/complete-notification.jpg
vendored
Normal file
BIN
docs/static/img/complete-notification.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 130 KiB |
Loading…
Reference in a new issue