MoceanAPI Client Library for Go
This is the Go library for use Mocean's API. To use this, you'll need a Mocean account. Sign up for free at moceanapi.com.
To install the client
go get "gopkg.in/MoceanAPI/mocean-sdk-go.v2"
Create a client with your API key and secret
import "gopkg.in/MoceanAPI/mocean-sdk-go.v2"
mocean := moceansdk.NewMoceanClient("apiKey", "apiSecret")
mocean.Message().Send() //Send SMS
mocean.Message().GetMessageStatus() //Get Message Status
mocean.Account().GetBalance() //Get Account Balance
mocean.Account().GetPricing() //Get Account Pricing
mocean.Verify().SendCode() //Send Verify Code
mocean.Verify().VerifyCode() //Check Verify Code
mocean.NumberLookup().Inquiry() //Number Lookup
mocean.Voice().Call() //Voice Call
To use Mocean's SMS API to send an SMS message, call the mocean.Message.Send()
method.
The API can be called directly, using a simple array of parameters, the keys match the parameters of the API.
res, err := mocean.Message().Send(url.Values{
"mocean-to": {"60123456789"},
"mocean-from": {"MOCEAN"},
"mocean-text": {"Hello World"}
})
if err != nil {
fmt.Println(err)
} else {
fmt.Printf("res: %v", res)
}
For your convenient, the API response has been parsed to specific struct
fmt.Printf("res: %v", res) // show full response string
fmt.Printf("res: %v", res.Status) // show response status, "0" in this case
Kindly visit MoceanApi Docs for more usage
This library is released under the MIT License