Last active
November 21, 2023 15:33
-
-
Save Kurtiii/bf12ede38590aed0f202dad2f50051d8 to your computer and use it in GitHub Desktop.
Create a Route-Code (routeto.page/api)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = 'https://routeto.page/api/v1/route-code/create'; | |
const data = `{ | |
"api_key": "[your_key]", | |
"destination_url": "https://kurtiii.de/pdf-reihenbriefe-mithilfe-von-excel-und-php-erstellen/" | |
}`; | |
const response = await fetch(url, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
body: data, | |
}); | |
const resp = await response.text(); | |
// Deal with the response (resp): | |
console.log(resp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = "https://routeto.page/api/v1/route-code/create"; | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_POST, true); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
$headers = array( | |
"Content-Type: application/json", | |
); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | |
$data = <<<DATA | |
{ | |
"api_key": "[your_key]", | |
"destination_url": "https://kurtiii.de/pdf-reihenbriefe-mithilfe-von-excel-und-php-erstellen/" | |
} | |
DATA; | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); | |
$resp = curl_exec($curl); | |
curl_close($curl); | |
// Deal with the response ($resp): | |
var_dump($resp); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from requests.structures import CaseInsensitiveDict | |
url = "https://routeto.page/api/v1/route-code/create" | |
headers = CaseInsensitiveDict() | |
headers["Content-Type"] = "application/json" | |
data = """ | |
{ | |
"api_key": "[your_key]", | |
"destination_url": "https://kurtiii.de/pdf-reihenbriefe-mithilfe-von-excel-und-php-erstellen/" | |
} | |
""" | |
resp = requests.post(url, headers=headers, data=data) | |
# Deal with the response (resp): | |
print(resp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"status":"success", // if status = error => "message" will contain error informations. | |
"data":{ | |
"route_code":"2594P", // the created route-code | |
"destination_url":"https://kurtiii.de/pdf-reihenbriefe-mithilfe-von-excel-und-php-erstellen/", // the url of the route code | |
"created_at":1697037758, // UNIX-timestamp of creation | |
"valid_until":1697124158, // UNIX-timestamp of deletion | |
"server_time":1700580418 // our server time => we use Berlin (CET/UTC+1) as our timezone (should be (nearly) the same as created_at) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment