Code-Beispiele
Beispiele
Ersetze TOKEN durch deinen API-Token und die Nummer durch deinen Empfänger.
curl
curl -X POST https://smsforge.de/api/sms \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{"to":["+491711234567"],"text":"Hallo von curl"}'PHP
<?php
$ch = curl_init('https://smsforge.de/api/sms');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer TOKEN', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['to' => ['+491711234567'], 'text' => 'Hallo von PHP']),
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), ' ', $response;Python
import requests # pip install requests
r = requests.post(
"https://smsforge.de/api/sms",
headers={"Authorization": "Bearer TOKEN"},
json={"to": ["+491711234567"], "text": "Hallo von Python"},
timeout=15,
)
print(r.status_code, r.json())PowerShell
$body = @{ to = @('+491711234567'); text = 'Hallo von PowerShell' } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri 'https://smsforge.de/api/sms' `
-Headers @{ Authorization = 'Bearer TOKEN' } `
-ContentType 'application/json; charset=utf-8' -Body ([Text.Encoding]::UTF8.GetBytes($body))GET-URL (Router, Monitoring, einfache Skripte)
https://smsforge.de/api/send?token=TOKEN&to=%2B491711234567&text=Hallo%20Welt