Ücretsiz Go 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.

Go 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 Go 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 Go 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.

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxx"
  body["api_key"] = "xxxxxxxxx"
  body["sender"] = "xxxxxxxxx"
  body["message_type"] = "normal"
  body["message"] = "test"
  body["message_content_type"] = "bilgi" // Ticari smsler için body["message_content_type"] = "ticari"
  body["phones"] = []string{"5xxxxxxxxx"}

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/1toN", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(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 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.

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxx"
  body["api_key"] = "xxxxxxxxx"
  body["sender"] = "xxxxxxxxx"
  body["message_type"] = "normal"
  // body["send_time"] = "2021-05-19 15:33:00" // İleri tarihli gönderim için.
  body["message_content_type"] = "bilgi" // Ticari smsler için body["message_content_type"] = "ticari"
  body["phones"] = []interface{}{
    map[string]interface{}{
      "phone":   "5xxxxxxxxx",
      "message": "Bu bir test mesajıdır.",
    },
    map[string]interface{}{
      "phone":   "5xxxxxxxxx",
      "message": "Bu bir test mesajıdır.",
    },
  }

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(string(requestBody))

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/NtoN", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(response)
}                                                                                    
                                                                                    

Gönderici Adı Sorgulama

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxxxxxxxx"
  body["api_key"] = "xxxxxxxxxxxxxxx"

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(string(requestBody))

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/senders", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(response)
}                                                                                    
                                                                                    

Kullanıcı Bilgilerini Alma

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxxxxxxxx"
  body["api_key"] = "xxxxxxxxxxxxxxx"

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(string(requestBody))

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/user/information", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(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ütn datayı almak istemiyorsanız page ve pageSize göndermemelisiniz.

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxx"
  body["api_key"] = "xxxxxxxxx"
  body["report_id"] = 000000

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(string(requestBody))

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/report/detail?page=1&pageSize=20", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(response)
}                                                                                    
                                                                                    

Rapor Sorgulama - Tarih Bazlı

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxx"
  body["api_key"] = "xxxxxxxxx"
  body["start_date"] = "2021-05-17 11:22:00"
  body["end_date"] = "2021-05-18 11:31:00"

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(string(requestBody))

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/report/between", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(response)
}                                                                                    
                                                                                    

Rapor Sorgulama - Sonu Sorgusu

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

                                                                                    
                                                                                    
package main
import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

func main() {

  body := make(map[string]interface{})

  body["api_id"] = "xxxxxxxxx"
  body["api_key"] = "xxxxxxxxx"
  body["report_id"] = 0000000

  requestBody, err := json.Marshal(body)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(string(requestBody))

  rawResponse, err := http.Post("https://api.vatansms.net/api/v1/report/single", "application/json", bytes.NewBuffer(requestBody))
  if err != nil {
    fmt.Println(err)
  }

  response := make(map[string]interface{})

  err = json.NewDecoder(rawResponse.Body).Decode(&response)
  if err != nil {
    fmt.Println(err)
  }

  fmt.Println(response)
}