This package provides a generic go client template for the Http SMS Api
httpsms-go is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/httpsms-goAlternatively the same can be achieved if you use import in a package:
import"github.com/NdoleStudio/httpsms-go"- Messages
POST /v1/messages/send: Send a new SMSGET /v1/messages: Get list of messages which are exchanged between 2 phone numbers.
- Heartbeats
GET /v1/heartbeats: Get the heartbeats of an Android Phone
- Message Threads
GET /v1/message-threads: Get the message threads of a phone numberDELETE v1/message-threads/:messageThreadID: Delete a message thread
- Cipher
Encrypt: Encrypt the content of a message to cipher textDecrypt: Decrypt an encrypted message content to plain text
- Phones
PUT /v1/phones: Create or update a phonePUT /v1/phones/fcm-token: Bind an FCM token to a phone
- Phone API Keys
POST /v1/phone-api-keys/: Create a new phone API key
- Webhooks
POST /v1/webhooks: Create a new webhook
An instance of the client can be created using httpsms.New().
package main
import (
"github.com/NdoleStudio/httpsms-go"
)
funcmain() {
client:=htpsms.New(htpsms.WithAPIKey(/* API Key from https://httpsms.com/settings */))
}All API calls return an error as the last return object. All successful calls will return a nil error.
_, response, err:=client.Messages.Send(context.Background())
iferr!=nil {
//handle error
}message, response, err:=client.Messages.Send(context.Background(), &MessageSendParams{
Content: "This is a sample text message",
From: "+18005550199",
To: "+18005550100",
})
iferr!=nil {
log.Fatal(err)
}
log.Println(message.Code) // 202You can run the unit tests for this client from the root directory using the command below:
go test -vThis project is licensed under the MIT License - see the LICENSE file for details
