-
-
Save ivajloip/bae390ed5eae9b28ed551bf5673dc88b to your computer and use it in GitHub Desktop.
Sending an SMS Text Message using AWS SNS service in GoLang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//assumes you have the following environment variables setup for AWS session creation | |
// AWS_SDK_LOAD_CONFIG=1 | |
// AWS_ACCESS_KEY_ID=XXXXXXXXXX | |
// AWS_SECRET_ACCESS_KEY=XXXXXXXX | |
// AWS_DEFAULT_REGION=us-east-1 | |
package main | |
import ( | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/sns" | |
) | |
func main() { | |
fmt.Println("creating session") | |
sess := session.Must(session.NewSession()) | |
fmt.Println("session created") | |
svc := sns.New(sess) | |
fmt.Println("service created") | |
params := &sns.PublishInput{ | |
Message: aws.String("testing 123"), | |
PhoneNumber: aws.String("+14445556666"), | |
} | |
resp, err := svc.Publish(params) | |
if err != nil { | |
// Print the error, cast err to awserr.Error to get the Code and | |
// Message from an error. | |
fmt.Println(err.Error()) | |
return | |
} | |
// Pretty-print the response data. | |
fmt.Println(resp) | |
} |
I am sorry, but this is from so long ago, that I am not certain if it will work anymore or how to really change it. Feel free to look for official documentation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to send sms to receiver number with mobile number