apprise-api/apprise_api/api/templates/welcome.html
2023-05-15 17:10:15 -04:00

646 lines
32 KiB
HTML

{% extends 'base.html' %}
{% load i18n %}
{% block body %}
<h4>{% trans "The Apprise API" %}</h4>
<p>
{% blocktrans %}
<a target="_blank" href="https://github.com/caronc/apprise">Apprise</a> allows you to send a notification to almost
all of the most popular notification services available to us today such as: <em>Telegram</em>, <em>Discord</em>,
<em>Slack</em>, <em>Amazon SNS</em>, <em>Gotify</em>, etc.
This API provides a simple gateway to directly access it via an HTTP interface.{% endblocktrans %}
<ul>
<li><i class="tiny material-icons">chevron_right</i>{% blocktrans %}This project was designed to be incredibly light
weight.{% endblocktrans %}</li>
<li><i class="tiny material-icons">chevron_right</i>{% blocktrans %}Configuration can be persistently stored for
retrieval.{% endblocktrans %}</li>
</ul>
</p>
<div class="section">
<h4>{% trans "Stateless Endpoints" %}</h4>
<p>{% blocktrans %}Those who wish to treat this API as nothing but a <a
href="https://docs.microsoft.com/en-us/azure/architecture/patterns/sidecar" target="_blank">sidecar</a> and/or
microservice to their project only need to use the following URL.{% endblocktrans %}</p>
<table class="highlighted">
<thead>
<tr>
<th style="min-width: 18%;">{% trans "URL" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>{{BASE_URL}}/notify/</code></td>
<td>
{% blocktrans %}Used to notify one one or more specified Apprise URLs. See the <a target="_blank"
href="https://github.com/caronc/apprise/wiki#notification-services">Apprise Wiki</a> if you need help
constructing your URL(s).{% endblocktrans %}
<div class="section">
<table>
<thead>
<tr>
<th>{% trans "Parameter" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>urls</td>
<td>{% blocktrans %}Used to define one or more Apprise URL(s). Use a comma and/or space to separate
one URL from the next.{% endblocktrans %}</td>
</tr>
<tr>
<td>body</td>
<td>{% blocktrans %}Defines the message body. This field is required!{% endblocktrans %}</td>
</tr>
<tr>
<td>title</td>
<td>{% blocktrans %}The title to include in the notification. This is an optional
field.{% endblocktrans %}
</td>
</tr>
<tr>
<td>type</td>
<td>{% blocktrans %}This optional field defines the notification type. The possible options
are:{% endblocktrans %}
<ol>
<li><i class="tiny material-icons" style="color: blue">info</i><code>{% trans "info" %}</code> -
<i>{% blocktrans %}this is the default option if a type
isn't
specified.{% endblocktrans %}</i></li>
<li><i class="tiny material-icons"
style="color: green">check_circle</i><code>{% trans "success" %}</code></li>
<li><i class="tiny material-icons"
style="color: orange">report_problem</i><code>{% trans "warning" %}</code></li>
<li><i class="tiny material-icons" style="color: red">cancel</i><code>{% trans "failure" %}</code>
</li>
</ol>
</td>
</tr>
</tbody>
</table>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Curl Example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Notifies an email address{% endblocktrans %}<br/>
curl -X POST -d '{"urls":"mailto://user:pass@gmail.com","body":"test body","title":"test title"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/"
<br/><br/>
# {% blocktrans %}Notifies an email address with attachments{% endblocktrans %}<br/>
curl -X POST -F 'urls=mailto://user:pass@gmail.com' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F 'title=test title' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F 'body=test body' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F attach1=@/path/to/attachment.doc \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F attach2=@Screenshot-2.png \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/"
</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Python Example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls': 'mailto://user:pass@gmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title': 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body': 'test body',<br/>
}<br/>
<br/># The Request<br/>
response = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
<br/>
</code></pre>
<pre><code class="python">
# {% blocktrans %}Notifies an email address with attachments{% endblocktrans %}<br/>
import requests<br/><br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls': 'mailto://user:pass@gmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title': 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body': 'test body',<br/>
}<br/><br/>
with open("my/path/to/attachment.png", 'rb') as fp:<br/>
&nbsp;&nbsp;&nbsp;&nbsp;response = request.post("{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data=payload,<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;files={'attach1':('attachment.png', fp)},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;)
</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>PHP Example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL<br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//The JSON data.<br/>
$jsonData = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls' => 'mailto://user:pass@hotmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body' => 'test body'<br/>
);<br/>
<br/>
//Encode the array into JSON.<br/>
$jsonDataEncoded = json_encode($jsonData);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our encoded JSON string to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);<br/>
<br/>
//Set the content type to application/json<br/>
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);<br/>
<br/>
// Close our handler<br/>
curl_close($ch);<br/>
?>
</code></pre>
<pre><code class="php">&lt;?php<br/>
// Sending an Attachment using PHP<br/><br/>
// The URL<br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
// Prepare our File attachment<br/>
$path = '/path/to/photo.jpg';<br/>
<br/>
// Acquire our Filename<br/>
$fname = basename($path);<br/>
<br/>
// Get our attachment mime-type (in this case it's 'image/jpg')<br/>
$mimeType = mime_content_type($path);<br/>
<br/>
//The multipart data.<br/>
$data = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls' => 'mailto://user:pass@hotmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body' => 'test body',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'attach1' => new CURLFile($path, $mimeType, $fname)<br/>
);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our data to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);<br/>
<br/>
// Close our handler<br/>
curl_close($ch);<br/>
?>
</code></pre>
</div>
</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
{% if STATEFUL_MODE != 'disabled' %}
<div class="section">
<h4>{% trans "Persistent Store Endpoints" %}</h4>
<p>{% blocktrans %}Those wishing to use the persistent store may do so. This section is a set it and forget it type
deal. Set your configuration once and just trigger notifications later on demand with light-weight API
calls.{% endblocktrans %}</p>
<p>{% blocktrans %}All endpoints that expect posted data can be received in either JSON or in it's standard
encoding.
You must pass along the <code>Content-Type</code> as <code>application/json</code> in order for it to be
interpreted
properly.{% endblocktrans %}</p>
<table class="highlighted">
<thead>
<tr>
<th style="min-width: 18%;">{% trans "URL" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>{{BASE_URL}}/add/<em>{{key}}</em></code></td>
<td>
{% blocktrans %}Used to add a new Apprise configuration or a set of URLs and associates them with configuration
identified with the id of <em>{{key}}</em>. See the <a target="_blank"
href="https://github.com/caronc/apprise/wiki#notification-services">Apprise Wiki</a> if you need help
constructing your URLs.{% endblocktrans %}
<div class="section">
<table>
<thead>
<tr>
<th>{% trans "Parameter" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>urls</td>
<td>{% blocktrans %}Used to define one or more Apprise URL(s). Use a comma and/or space to separate
one URL from the next.{% endblocktrans %}</td>
</tr>
<tr>
<td>config</td>
<td>{% blocktrans %}Provide the contents of either a YAML or TEXT based Apprise
configuration.{% endblocktrans %}</td>
</tr>
<tr>
<td>format</td>
<td>{% blocktrans %}This field is only required if you've specified the config option. It's purpose
is
to tell the server which of the supported (Apprise) configuration types you are passing. Valid
options are:{% endblocktrans %}
<ol>
<li><code>{% trans "yaml" %}</code></li>
<li><code>{% trans "text" %}</code></li>
</ol>
<ul>
<li>{% blocktrans %}You must specify either the <code>urls</code> parameter or the
<code>config</code>.{% endblocktrans %}</li>
<li>{% blocktrans %}The <code>urls</code> takes priority over the <code>config</code> if both
were
specified.{% endblocktrans %}</li>
<li>{% blocktrans %}The <code>format</code> parameter is only required if the
<code>config</code>
parameter was also specified.{% endblocktrans %}</li>
</ul>
</td>
</tr>
</tbody>
</table>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Curl Example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Load a single URL and assign it to: <em>{{key}}</em>{% endblocktrans %}<br/>
curl -X POST -d '{"urls":"mailto://user:pass@gmail.com"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/<em>{{key}}</em></code></pre>
<pre><code class="bash">
# {% blocktrans %}Load a simple TEXT config entry sent to: <em>{{key}}</em>{% endblocktrans %}<br/>
curl -X POST -d '{"format":"text","config":"devops=mailto://user:pass@gmail.com"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/{{key}}/
</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Python Example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls': 'mailto://user:pass@gmail.com',<br/>
}<br/>
<br/># The URL if the key was <em>{{key}}</em><br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/<em>{{key}}</em>",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>PHP Example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL if the key was <em>{{key}}</em><br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/<em>{{key}}</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//The JSON data.<br/>
$jsonData = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls' => 'mailto://user:pass@hotmail.com'<br/>
);<br/>
<br/>
//Encode the array into JSON.<br/>
$jsonDataEncoded = json_encode($jsonData);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our encoded JSON string to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);<br/>
<br/>
//Set the content type to application/json<br/>
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);<br/>
<br/>
// Close our handler<br/>
curl_close($ch);<br/>
?>
</code></pre>
</div>
</li>
</ul>
</div>
</td>
</tr>
<tr>
<td><code>{{BASE_URL}}/del/<em>{{key}}</em></code></td>
<td>{% blocktrans %}There are no arguments required. If configuration id of <em>{{key}}</em> exists and has data associated with
it, it will be removed.{% endblocktrans %}
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Curl Example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Remove previously loaded configuration associated with the id of <em>{{key}}</em>{% endblocktrans %}<br/>
curl -X POST {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/del/<em>{{key}}</em></code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Python Example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/># The request if the key was <em>{{key}}</em><br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/del/<em>{{key}}</em>",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
<li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>PHP Example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL if the key was <em>{{key}}</em><br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/del/<em>{{key}}</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);<br/>
<br/>
// Close our handler<br/>
curl_close($ch);<br/>
?>
</code></pre>
</div>
</li>
</ul>
</td>
</tr>
<tr>
<td><code>{{BASE_URL}}/get/<em>{{key}}</em></code></td>
<td>{% blocktrans %}This feature can be used by Apprise itself. It provides a means of remotely fetching it's
the configuration associated with the configuration identified through the id of <em>{{key}}</em>.{% endblocktrans %}<br />
<pre><code lang="bash"># Use Apprise to retrieve your configuration:<br/>
apprise --body="test message" --config={{ request.scheme }}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
</p>
</td>
</tr>
<tr>
<td><code>{{BASE_URL}}/notify/<em>{{key}}</em></code></td>
<td>{% blocktrans %}Notifies the URLs associated with configuration identified by the id of <em>{{key}}</em>.{% endblocktrans %}
<div class="section">
<table>
<thead>
<tr>
<th>{% trans "Parameter" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>body</td>
<td>{% blocktrans %}Defines the message body. This field is required!{% endblocktrans %}</td>
</tr>
<tr>
<td>title</td>
<td>{% blocktrans %}The title to include in the notification. This is an optional
field.{% endblocktrans %}
</td>
</tr>
<tr>
<td>type</td>
<td>{% blocktrans %}This optional field defines the notification type. The possible options
are:{% endblocktrans %}
<ol>
<li><i class="tiny material-icons" style="color: blue">info</i><code>{% trans "info" %}</code> -
<i>{% blocktrans %}this is the default option if a type
isn't
specified.{% endblocktrans %}</i></li>
<li><i class="tiny material-icons"
style="color: green">check_circle</i><code>{% trans "success" %}</code></li>
<li><i class="tiny material-icons"
style="color: orange">report_problem</i><code>{% trans "warning" %}</code></li>
<li><i class="tiny material-icons"
style="color: red">cancel</i><code>{% trans "failure" %}</code></li>
</ol>
</td>
</tr>
<tr>
<td>tag</td>
<td>{% blocktrans %}Apply tagging logic to the further filter your URLs. This is an optional
field.{% endblocktrans %}</td>
</tr>
</tbody>
</table>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Curl Example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Notifies all URLs assigned to the configuration{% endblocktrans %}<br/>
curl -X POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tag=all" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "body=test body" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "title=test title" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre>
<pre><code class="bash">
# {% blocktrans %}Notifies all URLs assigned the <em>devops</em> tag{% endblocktrans %}<br/>
curl -X POST -d '{"tag":"devops","body":"test body","title":"test title"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>Python Example</div>
<div class="collapsible-body">
Ideally you should leverage the Apprise Library, it will make your life much easier:
<pre><code class="python">
import apprise<br/>
<br/>
# Create an Apprise Instance<br/>
aobj = apprise.Apprise()<br/>
<br/>
# Add our URL</br>
aobj.add("apprise{% if secure %}s{%else%}{%endif%}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>")<br/>
<br/>
# Send our notification:<br/>
aobj.notify("test body", "test title")<br/>
<br/>
# Sending an attachment is just as easy:<br/>
aobj.notify("test body", "test title", attach="/path/to/file")<br/>
</code></pre>
The legacy (but more compatible and light weight) way of doing things:
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'tag': 'devops',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title': 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body': 'test body',<br/>
}<br/>
<br/># The URL if the key was <em>{{key}}</em><br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
<li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>PHP Example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL if the key was <em>{{key}}</em><br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//The JSON data.<br/>
$jsonData = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'tag' => 'devops',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body' => 'test body'<br/>
);<br/>
<br/>
//Encode the array into JSON.<br/>
$jsonDataEncoded = json_encode($jsonData);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our encoded JSON string to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);<br/>
<br/>
//Set the content type to application/json<br/>
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);<br/>
<br/>
// Close our handler<br/>
curl_close($ch);<br/>
?>
</code></pre>
<pre><code class="php">&lt;?php<br/>
// Sending an Attachment using PHP<br/><br/>
// The URL<br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
// Prepare our File attachment<br/>
$path = '/path/to/photo.jpg';<br/>
<br/>
// Acquire our Filename<br/>
$fname = basename($path);<br/>
<br/>
// Get our attachment mime-type (in this case it's 'image/jpg')<br/>
$mimeType = mime_content_type($path);<br/>
<br/>
//The multipart data.<br/>
$data = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls' => 'mailto://user:pass@hotmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body' => 'test body',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'attach1' => new CURLFile($path, $mimeType, $fname)<br/>
);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our data to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);<br/>
<br/>
// Close our handler<br/>
curl_close($ch);<br/>
?>
</code></pre>
</div>
</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
<div class="section">
<h4>{% trans "Endpoint Notes" %}</h4>
<p>
The Configuration ID (<em>{{key}}</em>) you plan to associate your configuration with:
<ol>
<li>Can not have spaces and/or special characters in it. Both a dash (<code>-</code>) and underscore
(<code>_</code>) are the only exceptions to this rule.</li>
<li>Must start with at least 2 alpha/numeric characters.</li>
<li>Can not exceed 64 characters in total length.</li>
</ol>
</p>
</div>
</div>
{% else %}
<div class="section">
<h4>{% trans "Persistent Store Endpoints" %}</h4>
<p>{% blocktrans %}The administrator of this system has disabled persistent storage.{% endblocktrans %}</p>
</div>
{% endif %}
{% endblock %}