<?php
$url = '/v1/send_message.php';
$payload = [
'to' => '+48123456789',
'text' => 'Wiadomość testowa',
'sender' => 'client',
'external_id' => 'EXT-2025-001'
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer YOUR_API_KEY'
],
CURLOPT_POSTFIELDS => json_encode($payload)
]);
$res = curl_exec($ch);$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP $code\n";
echo $res;
curl -X POST '/v1/send_message.php' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"to":"+48123456789","text":"Wiadomość testowa","sender":"client","external_id":"EXT-2025-001"}'
{
"to": "+48123456789",
"text": "Wiadomość testowa",
"sender": "client",
"external_id": "EXT-2025-001"
}
import requests
url = '/v1/send_message.php'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
payload = {
'to': '+48123456789',
'text': 'Wiadomość testowa',
'sender': 'client',
'external_id': 'EXT-2025-001'
}
r = requests.post(url, headers=headers, json=payload, timeout=30)
print(r.status_code)
print(r.text)
// Kotlin + OkHttp
val url = "/v1/send_message.php"
val json = """{
\"to\": \"+48123456789\",
\"text\": \"Wiadomość testowa\",
\"sender\": \"client\",
\"external_id\": \"EXT-2025-001\"
}"""
val client = okhttp3.OkHttpClient()
val body = okhttp3.RequestBody.create(
"application/json; charset=utf-8".toMediaType(),
json
)
val request = okhttp3.Request.Builder()
.url(url)
.addHeader("Authorization", "Bearer YOUR_API_KEY")
.post(body)
.build()
client.newCall(request).enqueue(object : okhttp3.Callback {
override fun onFailure(call: okhttp3.Call, e: java.io.IOException) {
e.printStackTrace()
}
override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
println(response.code)
println(response.body?.string())
}
})