This package provides a go
client for the SMS.to HTTP API https://developers.sms.to
smsto-go
is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/smsto-go
Alternatively the same can be achieved if you use import
in a package:
import "github.com/NdoleStudio/smsto-go"
- SMS
POST /sms/send
: Send single message to a numberGET /last/message
: Get the last message that you have sent
An instance of the client can be created using New()
.
package main
import (
"github.com/NdoleStudio/smsto-go"
)
func main() {
client := smsto.New(smsto.WithAPIKey(/* API KEY */))
}
All API calls return an error
as the last return object. All successful calls will return a nil
error.
result, response, err := client.SMS.SendSingle(context.Background(), &smsto.SmsSendSingleRequest{})
if err != nil {
//handle error
}
result, response, err := client.SMS.SendSingle(context.Background(), &SmsSendSingleRequest{
Message: "This is test and \n this is a new line",
To: "+35799999999999",
})
if err != nil {
log.Fatal(err)
}
log.Println(result.Success) // true
message, response, err := client.SMS.LastMessage(context.Background())
if err != nil {
log.Fatal(err)
}
log.Println(message.Id) // 302050741
You can run the unit tests for this client from the root directory using the command below:
go test -v
This project is licensed under the MIT License - see the LICENSE file for details