Skip to content

dmitriy-borisov/go-smsru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang-client for the SMS.ru API

Build Status GoDoc

Supports:

  • sms/send, sms/status, sms/cost
  • my/balance, my/limit, my/senders
  • stoplist/get, stoplist/add, stoplist/del
  • callback/get, callback/add, callback/del

Installation

Install:

go get github.com/dmitriy-borisov/go-smsru

Import:

import "github.com/dmitriy-borisov/go-smsru"

Examples

package main

import (
    "log"
    "github.com/dmitriy-borisov/go-smsru"
)

const API_ID = "MY_API_ID"

func main() {
    client := sms.NewClient(API_ID)
    
    // Send one message
    msg := sms.NewSms("79250001122", "Sample text")
    
    res, err := client.SmsSend(msg)
    if err != nil {
        log.Panic(err)
    } else {
        log.Printf("Status = %d, Id = %s, Balance = %f", res.Status, res.Ids[0], res.Balance)
    }
    
    // Send multiple messages
    msg := sms.NewSms("79250001122", "Sample text")
    msg2 := sms.NewSms("79251112233", "Sample text")
    multi := sms.NewMulti(msg, msg2)
    
    res, err := client.SmsSend(multi)
    if err != nil {
        log.Panic(err)
    } else {
        log.Printf("Status = %d, Ids = %v, Balance = %f", res.Status, res.Ids, res.Balance)
    }
}

Tests

phone=YOUR_PHONE api_id=YOUR_API_ID go test

Releases

No releases published

Packages

No packages published

Languages