Learn R Programming

aws.sns (version 0.1.7)

publish: Publish to a topic or endpoint

Description

Publish a message to a specified topic or application endpoint.

Usage

publish(topic, endpoint, message, subject, ...)

Arguments

topic

Optionally, a character string containing an SNS Topic Amazon Resource Name (ARN). Must specify topic or endpoint.

endpoint

Optionally, a character string containing an SNS Application Endpoint ARN. Must specify topic or endpoint.

message

Either a single character string containing a message to be sent to all endpoints, or a named list of messages to be sent to specific endpoints (where the names of each element correspond to endpoints).

subject

Optionally, a character string containing a subject line (e.g., to be used for an email endpoint).

...

Additional arguments passed to snsHTTP.

Value

If successful, a character string containing a message ID. Otherwise, a data structure of class “aws_error” containing any error message(s) from AWS and information about the request attempt.

Details

Publishes a message to a topic or an application endpoint. Messages can be the same for all endpoints or customized so that, for example, a short 140-character message is sent to SMS endpoints that are subscribed to a topic while longer messages are sent to email endpoints, etc. The allowed message types are: default, email, email-json, sqs, sms, http, https, and application.

References

Publish

Examples

Run this code

  top <- create_topic("new_topic")

  # simple notifications
  publish(top, message = "This is a notification message", subject = "Notification!")

  # endpoint-specific notification
  publish(top, message = list(sms = "This is an sms message", 
                              email = "This is an email"), 
          subject = "Notification!")

  delete_topic(top)


Run the code above in your browser using DataLab