messagemedia_messages_sdk

package module
v0.0.0-...-4b08ca5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2018 License: Apache-2.0 Imports: 0 Imported by: 0

README ยถ

MessageMedia Messages Go SDK

Travis Build Status Pull Requests Welcome

The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.

Isometric

Table of Contents

๐Ÿ” Authentication

Authentication is done via API keys. Sign up at https://developers.messagemedia.com/register/ to get your API keys.

Requests are authenticated using HTTP Basic Auth or HMAC. Provide your API key as the auth_user_name and API secret as the auth_password.

โ‰ Errors

Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The most common status codes are listed below.

HTTP Status Codes
Code Title Description
400 Invalid Request The request was invalid
401 Unauthorized Your API credentials are invalid
403 Disabled feature Feature not enabled
404 Not Found The resource does not exist
50X Internal Server Error An error occurred with our API

๐Ÿ“ฐ Information

Slack and Mailing List

If you have any questions, comments, or concerns, please join our Slack channel: https://developers.messagemedia.com/collaborate/slack/

Alternatively you can email us at: developers@messagemedia.com

Bug reports

If you discover a problem with the SDK, we would like to know about it. You can raise an issue or send an email to: developers@messagemedia.com

Contributing

We welcome your thoughts on how we could best provide you with SDKs that would simplify how you consume our services in your application. You can fork and create pull requests for any features you would like to see or raise an issue

โญ Installation

Run the following command via Go Get:

go get github.com/messagemedia/messages-go-sdk

๐ŸŽฌ Get Started

It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below and a mobile number you wish to send to.

Send an SMS

Destination numbers (destination_number) should be in the E.164 format. For example, +61491570156.

package main

import (
    "encoding/json"
    "fmt"
    "github.com/messagemedia/messages-go-sdk"
    "github.com/messagemedia/messages-go-sdk/messages_pkg"
    "github.com/messagemedia/messages-go-sdk/models_pkg"
)

func main() {
    messagemedia_messages_sdk.Config.BasicAuthUserName = "YOUR_API_KEY"
    messagemedia_messages_sdk.Config.BasicAuthPassword = "YOUR_SECRET_KEY"

    messages := messages_pkg.NewMESSAGES()
    bodyValue := []byte(`{
        "messages": [{
            "content": "My first message",
            "destination_number": "YOUR_MOBILE_NUMBER",
            "format": "SMS"
        }]
    }`)

    var body *models_pkg.SendMessagesRequest
    json.Unmarshal(bodyValue, &body)

    result, err := messages.CreateSendMessages(body)
    fmt.Println(result, err)
}
Send an MMS

Destination numbers (destination_number) should be in the E.164 format. For example, +61491570156.

package main

import (
    "encoding/json"
    "fmt"
    "github.com/MessageMedia/messages-go-sdk"
    "github.com/MessageMedia/messages-go-sdk/messages_pkg"
    "github.com/MessageMedia/messages-go-sdk/models_pkg"
)

func main() {
    messagemedia_messages_sdk.Config.BasicAuthUserName = "YOUR_API_KEY"
    messagemedia_messages_sdk.Config.BasicAuthPassword = "YOUR_SECRET_KEY"

    messages := messages_pkg.NewMESSAGES()
    bodyValue := []byte(`{
       "messages":[
         {
            "content":"Test",
            "destination_number":"YOUR_MOBILE_NUMBER",
            "format": "MMS",
            "media":["https://upload.wikimedia.org/wikipedia/commons/6/6a/L80385-flash-superhero-logo-1544.png"]
         }
       ]
    }`)

    var body *models_pkg.SendMessagesRequest
    json.Unmarshal(bodyValue, &body)

    result, err := messages.CreateSendMessages(body)
    fmt.Println(result, err)
}
Get Status of a Message

You can get a messsage ID from a sent message by looking at the message_id from the response of the above example.

package main

import (
    "fmt"
    "github.com/messagemedia/messages-go-sdk"
    "github.com/messagemedia/messages-go-sdk/messages_pkg"
)

func main() {
    messagemedia_messages_sdk.Config.BasicAuthUserName = "YOUR_API_KEY"
    messagemedia_messages_sdk.Config.BasicAuthPassword = "YOUR_SECRET_KEY"

    messages := messages_pkg.NewMESSAGES()
    messageId := "YOUR_MESSAGE_ID"

    var result interface{}
    result,_ = messages.GetMessageStatus(messageId)

    fmt.Println(result)
}

Get replies to a message

You can check for replies that are sent to your messages

package main

import (
    "fmt"
    "github.com/messagemedia/messages-go-sdk"
    "github.com/messagemedia/messages-go-sdk/replies_pkg"
    "github.com/messagemedia/messages-go-sdk/models_pkg"
)

func main() {
    messagemedia_messages_sdk.Config.BasicAuthUserName = "YOUR_API_KEY"
    messagemedia_messages_sdk.Config.BasicAuthPassword = "YOUR_API_SECRET"

    replies := replies_pkg.NewREPLIES()

    var result *models_pkg.CheckRepliesResponse
    result,_ = replies.GetCheckReplies()

    fmt.Println(result)
}

Check Delivery Reports

This endpoint allows you to check for delivery reports to inbound and outbound messages.

package main

import (
    "fmt"
    "github.com/messagemedia/messages-go-sdk"
    "github.com/messagemedia/messages-go-sdk/deliveryreports_pkg"
    "github.com/messagemedia/messages-go-sdk/models_pkg"
)

func main() {
    messagemedia_messages_sdk.Config.BasicAuthUserName = "YOUR_API_KEY"
    messagemedia_messages_sdk.Config.BasicAuthPassword = "YOUR_API_SECRET"

    deliveryReports := deliveryreports_pkg.NewDELIVERYREPORTS()

    var result *models_pkg.CheckDeliveryReportsResponse
    result,_ = deliveryReports.GetCheckDeliveryReports()

    fmt.Println(result)
}

๐Ÿ“• API Reference Documentation

Check out the full API documentation for more detailed information.

๐Ÿ˜• Need help?

Please contact developer support at developers@messagemedia.com or check out the developer portal at developers.messagemedia.com

๐Ÿ“ƒ License

Apache License. See the LICENSE file.

Documentation ยถ

Index ยถ

Constants ยถ

View Source
const BASEURI string = "https://api.messagemedia.com"

* The base Uri for API calls

Variables ยถ

View Source
var Config struct {
	/** The username to use with basic authentication */
	/** Replace the value of BasicAuthUserName with an appropriate value */
	BasicAuthUserName string
	/** The password to use with basic authentication */
	/** Replace the value of BasicAuthPassword with an appropriate value */
	BasicAuthPassword string
}

Functions ยถ

This section is empty.

Types ยถ

This section is empty.

Directories ยถ

Path Synopsis
* messagemedia_messages_sdk * *
* messagemedia_messages_sdk * *
* messagemedia_messages_sdk * *
* messagemedia_messages_sdk * *
* messagemedia_messages_sdk * *
* messagemedia_messages_sdk * *

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL