Ücretsiz PHP SMS API Entegrasyonu

Güvenlik, bilgilendirme ve tanıtım mesajlarınızı otomatikleştirin. Müşterilerinizi her durumda otomatik olarak gidecek mesajlarla anında haberdar edin, iletişiminiz ve marka değeriniz yükselsin. En çok kullanılan yazılım dillerine göre hazırladığımız örnek kodlarımızı inceleyin.

PHP dilinde oluşturduğumuz SMS API servisimizi VatanSMS kullanıcı adı ve şifre bilgilerinizi girerek kolayca sisteminize entegre edebilir ve mesaj gönderimini otomatik hale getirebilirsiniz.


Kod Örnekleri

Sisteminize kolayca entegre edebileceğiniz PHP SMS API servisimiz ile müşterilerinize şifre doğrulama, otomatik onay veya bilgi mesajları gönderin. Toplu SMS gönderimi gibi birçok avantaj elde edeceğiniz PHP SMS API scripti örnek ve dokümanlarımızı inceleyin.

1 - N

sender olarak hesabınıza tanımlanmış olan gönderici adını göndermelisiniz. Türkçe SMS gnderimi için 'message_type': turkce olarak gönderilmelidir.

İleri tarihli SMS göndermek için datanın içerisine 'send_time' : '2021-05-25 12:00:00' (Y-m-d H:i:s) şeklinde gönderilmedilir. Hemen gönderim yapmak için send_time'ı göndermemelisiniz.

                                                                                    
                                                                                    
<?php

$curl = curl_init();

$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', // ticari smsler için 'ticari'
  'phones' => [
    '5xxxxxxxxx',
    '5xxxxxxxxx'
  ]
];

$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/1toN',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];

curl_setopt_array($curl, $curl_options);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

?>                                                                                    
                                                                                    

N - N

sender olarak hesabınıza tanımlanmış olan gönderici adını göndermelisiniz. Türkçe SMS gönderimi için 'message_type': turkce olarak gönderilmelidir.

İleri tarihli SMS göndermek iin datanın içerisine 'send_time' : '2021-05-25 12:00:00' (Y-m-d H:i:s) şeklinde gönderilmedilir. Hemen gönderim yapmak için send_time'ı göndermemelisiniz.

                                                                                    
                                                                                    
<?php

$curl = curl_init();
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'sender' => 'SMSBASLIGINIZ',
  'message_type' => 'normal',
  "send_time" => "2021-05-19 15:33:00",
  'message_content_type' => 'bilgi', // ticari smsler için 'ticari'
  'phones' => [
    [
      "phone" => "5xxxxxxxxx",
      "message" => "Bu bir test mesajıdır."
    ],
    [
      "phone" => "5xxxxxxxxx",
      "message" => "Bu bir test mesajıdır."
    ]
  ]
];

$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/NtoN',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];

curl_setopt_array($curl, $curl_options);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

?>                                                                                    
                                                                                    

Gönderici Adı Sorgulama

                                                                                    
                                                                                    
<?php

$curl = curl_init();
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY'
];

$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/senders',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];

curl_setopt_array($curl, $curl_options);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

?>                                                                                    
                                                                                    

Kullanıcı Bilgilerini Alma

                                                                                    
                                                                                    
<?php

$curl = curl_init();
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY'
];

$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/user/information',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];

curl_setopt_array($curl, $curl_options);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

?>                                                                                    
                                                                                    

Rapor Sorgulama - Rapor Detayı

report_id her SMS gönderimi sonrasında dönen id değeridir.

Eğer datanın sayfalamalı dönmesini istiyorsana url içerisinde page'i göndermeniz gerekmektedir. Sayfalar default olarak 20 şerli dönmektedir. Eğer isterseniz 1-100 arasında bir değeri pageSize'da göndererek değiştirebilirsiniz.

Eğer direkt sayfalamasız olarak bütün datayı almak istemiyorsanız page ve pageSize göndermemelisiniz.

                                                                                    
                                                                                    
<?php

$curl = curl_init();
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  'report_id' => 926410
];

$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/report/detail?page=1&pageSize=20',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];


curl_setopt_array($curl, $curl_options);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

?>                                                                                    
                                                                                    

Rapor Sorgulama - Tarih Bazlı

                                                                                    
                                                                                    
<?php

$curl = curl_init();
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  "start_date" => "2021-05-17 11:22:00",
  "end_date" => "2021-05-18 11:31:00"
];

$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/report/between',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];


curl_setopt_array($curl, $curl_options);

$response = curl_exec($curl);

curl_close($curl);

echo $response;

?>                                                                                    
                                                                                    

Rapor Sorgulama - Sonuç Sorgusu

report_id her SMS gönderimi sonrasında dönen id değeridir.

                                                                                    
                                                                                    
<?php

$curl = curl_init();
$params = [
  'api_id' => 'API_ID',
  'api_key' => 'API_KEY',
  "report_id" => 926382
];
$curl_options = [
  CURLOPT_URL => 'https://api.vatansms.net/api/v1/report/single',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POSTFIELDS => json_encode($params),
  CURLOPT_HTTPHEADER => [
    'Content-Type: application/json'
  ]
];
curl_setopt_array($curl, $curl_options);
$response = curl_exec($curl);
curl_close($curl);
echo $response;

?>