I have the AWS SDK for PHP installed in the webserver and can create a queue, send/delete a test message. I then tried to check if I can send a json (text or object) from using curl. Somehow it's not getting the message. If I change the variable ($json) in the 'MessageBody' to a string and run the php script manually, the string gets forwarded to the queue. Any ideas?
<?php
require 'SQS/aws-autoloader.php';
use Aws\Sqs\SqsClient;
use Aws\Exception\AwsException;
header("Content-Type: application/json");
$json = file_get_contents('php://input');
error_log( print_r( $json, true ));
$client = new SqsClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => 'latest'
]);
$client->sendMessage(array(
'QueueUrl' => "https://sqs.us-east-1.amazonaws.com/xxxxxxxxxx/xxxxxxxxxx",
'MessageBody' => $json
));
Here is the cURL request:
curl -v http://xx.xxx.xxx.xxx/somesite/somescript.php -d '{"hello":"world"}' -H "Content-Type: application/json"