Skip to content

MoceanAPI/mocean-sdk-go

Repository files navigation

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.

Installation

To install the client

go get "gopkg.in/MoceanAPI/mocean-sdk-go.v2"

Usage

Create a client with your API key and secret

import "gopkg.in/MoceanAPI/mocean-sdk-go.v2"

mocean := moceansdk.NewMoceanClient("apiKey", "apiSecret")

Available API

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

Example

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)
}

Responses

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

Documentation

Kindly visit MoceanApi Docs for more usage

License

This library is released under the MIT License