PHP ile SMS gönderme: hazır örnek kodlar

cURL ile; Laravel, WordPress ve her PHP projesinde çalışır. Her istek POST, gövde JSON; api_id ve api_key panelde Hesabım → API Bilgilerimi Görüntüle bölümünde.

Taban adres: https://api.toplusmspaketleri.com/api/v1 · Demo hesapta deneme için 10 kredi tanımlanır. Kodu tarayıcıda değil sunucuda çalıştırın; api_key gizli kalmalı.

1 - N gönderim

POST/1toN

Aynı mesajı bir ya da birden çok numaraya gönderir.

  • sender olarak hesabınıza tanımlı gönderici adını (başlık) ya da 850'li numaranızı gönderin.
  • Türkçe karakter için message_type değerini turkce yapın.
  • İleri tarihli gönderim için send_time alanını Y-m-d H:i:s biçiminde ekleyin; hemen gönderim için bu alanı yazmayın.
  • Ticari içerikte message_content_type değeri ticari, bilgilendirmede bilgi olmalıdır.
<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'sender' => 'SMSBASLIGINIZ',
  'message_type' => 'normal',
  'message' => 'Bu bir test mesajıdır.',
  'message_content_type' => 'bilgi',
  'phones' => [
    '5xxxxxxxxx',
    '5xxxxxxxxx'
  ]
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/1toN',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

N - N gönderim

POST/NtoN

Her numaraya farklı mesaj gönderir (kişiye özel hitap, kod, tutar).

  • phones dizisindeki her öğe phone ve message alanı taşır.
  • send_time örneği ileri tarihli gönderimi gösterir; hemen gönderim için kaldırın.
<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'sender' => 'SMSBASLIGINIZ',
  'message_type' => 'normal',
  'send_time' => '2026-12-01 10:00:00',
  'message_content_type' => 'bilgi',
  'phones' => [
    [
      'phone' => '5xxxxxxxxx',
      'message' => 'Sayın Ayşe Yılmaz, siparişiniz kargoya verildi.'
    ],
    [
      'phone' => '5xxxxxxxxx',
      'message' => 'Sayın Ali Kaya, randevunuz yarın 14:00.'
    ]
  ]
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/NtoN',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

Gönderici adı sorgulama

POST/senders

Hesabınıza tanımlı gönderici adlarını (başlıkları) listeler.

<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY'
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/senders',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

Kullanıcı bilgilerini alma

POST/user/information

Hesap bilgisi ve kalan kredi.

<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY'
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/user/information',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

Rapor sorgulama: rapor detayı

POST/report/detail?page=1&pageSize=20

Bir gönderimin numara bazında teslimat durumu, sayfalı.

  • report_id her gönderimden sonra dönen kimliktir.
  • Sayfalama için adrese page ekleyin; varsayılan sayfa 20 kayıt, pageSize ile 1-100 arası.
  • Tüm veriyi sayfasız almak için page ve pageSize göndermeyin.
<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'report_id' => 926410
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/report/detail?page=1&pageSize=20',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

Rapor sorgulama: tarih bazlı

POST/report/between

Tarih aralığındaki gönderimlerin raporu.

  • start_date ve end_date Y-m-d H:i:s biçiminde olmalıdır.
<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'start_date' => '2026-11-01 00:00:00',
  'end_date' => '2026-11-30 23:59:59'
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/report/between',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

Rapor sorgulama: sonuç sorgusu

POST/report/single

Tek gönderimin sonuç özeti.

  • report_id her gönderimden sonra dönen kimliktir.
<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'report_id' => 926382
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/report/single',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;

İleri tarihli SMS iptali

POST/cancel/future-sms

Henüz gitmemiş ileri tarihli gönderimi iptal eder.

  • id alanına iptal edilecek gönderimin rapor kimliğini yazın.
<?php
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'id' => 926382
];

$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.toplusmspaketleri.com/api/v1/cancel/future-sms',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$response = curl_exec($curl);
curl_close($curl);

echo $response;
Yanıt kodları

200 başarılı (report_id döner) · 401 api bilgileri hatalı · 422 eksik alan ya da onaysız gönderici adı · 404 rapor bulunamadı.

API Soruları →

PHP entegrasyonunuz bugün çalışsın

Ücretsiz üyelik, anında api_id ve api_key, takıldığınızda teknik destek.