send_message ( $queue_url, $message_body, $opt )

The SendMessage action delivers a message to the specified queue.

Access

public

Parameters

Parameter

Type

Required

Description

$queue_url

string

Required

The URL of the SQS queue to take action on.

$message_body

string

Required

The message to send.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • DelaySeconds - integer - Optional - The number of seconds the message has to be delayed.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Send a message to your (US-East) queue.

// Send a message to the queue
$sqs = new AmazonSQS();
$response = $sqs->send_message('example-queue', 'This is my message.');

// Success?
var_dump($response->isOK());
Result:
bool(true)

Send a message to your EU-West queue.

// Send a message to the queue
$sqs = new AmazonSQS();
$sqs->set_region(AmazonSQS::REGION_EU_W1);
$response = $sqs->send_message('example-queue', 'This is my message.');

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/sqs.class.php | Toggle source view (8 lines) | View on GitHub

public function send_message($queue_url, $message_body, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['QueueUrl'] = $queue_url;
    $opt['MessageBody'] = $message_body;
    
    return $this->authenticate('SendMessage', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback