Skip to content

Instantly share code, notes, and snippets.

@btk
Created February 21, 2021 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btk/3a76a87495c1f95b407d000f2167e7bd to your computer and use it in GitHub Desktop.
Save btk/3a76a87495c1f95b407d000f2167e7bd to your computer and use it in GitHub Desktop.
const http = require('http');
const url = 'https://tenta.me/XXXXXX';
const options = {
method: 'POST',
headers: {
"Content-Type": "application/json; charset=utf-8"
}};
const request = http.request(url, options, (response) => {
console.log(response);
});
request.on('error', (e) => {
console.error(e);
});
request.write(JSON.stringify({
"title": "Your notification title",
"description": "Your notification description",
"options": {
"detail1": "first detail",
"detail2": "second detail"
}
}));
request.end();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://tenta.me/XXXXXX",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"title\": \"Your notification title\",\n \"description\": \"Your notification description\",\n \"options\": {\n \"detail1\": \"first detail\",\n \"detail2\": \"second detail\"\n }\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json; charset=utf-8"
)
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
import requests
url = 'https://tenta.me/XXXXXX'
headers = {
'Content-Type': 'application/json'
}
data = "{\n \"title\": \"Your notification title\",\n \"description\": \"Your notification description\",\n \"options\": {\n \"detail1\": \"first detail\",\n \"detail2\": \"second detail\"\n }\n}"
response = requests.request(
'POST',
'https://tenta.me/XXXXXX',
data=data,
headers=headers,
)
print(response)
wget -O - --method=POST \
'https://tenta.me/XXXXXX' \
--header='Content-Type: application/json; charset=utf-8' \
--body-data='{
"title": "Your notification title",
"description": "Your notification description",
"options": {
"detail1": "first detail",
"detail2": "second detail"
}
}'
fetch("https://tenta.me/XXXXXX", {
method: "POST",
body: JSON.stringify({
"title": "Your notification title",
"description": "Your notification description",
"options": {
"detail1": "first detail",
"detail2": "second detail"
}
}),
headers: {
"Content-Type": "application/json; charset=utf-8"
},
credentials: "same-origin"
}).then(function(response) {
response.status
response.statusText
response.headers
response.url
return response.text()
}).catch(function(error) {
error.message
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment