Last active
November 21, 2023 15:32
-
-
Save Kurtiii/89e4442f9feb6909fb0b5b1ab59340ea to your computer and use it in GitHub Desktop.
Check 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/check'; | |
const data = `{ | |
"api_key": "[your_key]", | |
"destination_url": "Z4MAB" | |
}`; | |
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/check"; | |
$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": "Z4MAB" | |
} | |
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/check" | |
headers = CaseInsensitiveDict() | |
headers["Content-Type"] = "application/json" | |
data = """ | |
{ | |
"api_key": "[your_key]", | |
"destination_url": "Z4MAB" | |
} | |
""" | |
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 currently checked 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment