Skip to content

lopezator/nexmo-go

Repository files navigation

Build Status Go Report Card GoDoc License: GPL v3

nexmo-go

Nexmo REST API client for Go.

Hugely inspired by: https://github.com/kevinburke/twilio-go

As it's a WIP it only supports SMS and TTS Call sending by now.

Install

Assuming you have your $GOPATH set:

$> go get github.com/lopezator/nexmo-go
$> cd $GOPATH/src/lopezator/nexmo-go
$> make install

Usage

nexmo-go is pretty straightforward to use, anyway, you can find some examples ready to run in the examples/ folder in addition to usage info below.

Send a SMS

const apiKey = "my-api-key"
const apiSecret = "my-api-secret"

// Create a client
client := nexmo.NewClient(apiKey, apiSecret, nil)

// Send a message
// Nexmo allows to use your either a random text as `from` value or your nexmo phone with country code but without "+" or "00" prefix
msg, err := client.Messages.SendMessage("ME", "34666666666", "Message sent via nexmo-go")

Make a TTS Call

const apiKey = "my-api-key"
const apiSecret = "my-api-secret"

// Create a client
client := nexmo.NewClient(apiKey, apiSecret, nil)

// Make a TTS call
msg, err := client.Calls.MakeTTSCall("15111111111", "34666666666", "TTS call sent via nexmo-go", "5")