Skip to content

Commit

Permalink
Take a first crack at creating an SQS class
Browse files Browse the repository at this point in the history
  • Loading branch information
waldoj committed Jan 24, 2018
1 parent 76bb7fc commit d611335
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions htdocs/includes/class.SQS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/**
* Interact with AWS’ Simple Queuing Service.
*/
class SQS
{

use Aws\Sqs\SqsClient;

public function __construct()
{

$this->sqs_client = new SqsClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => '2012-11-05',
'key' => AWS_ACCESS_KEY,
'secret' => AWS_SECRET_KEY
]);

}

/**
* Send a message via SQS.
*/
function send()
{

if (!isset($this->message))
{
return FALSE;
}

$this->sqs_client->sendMessage([
'MessageGroupId' => '1',
'MessageDeduplicationId' => mt_rand(),
'QueueUrl' => SQS_VIDEO_URL,
'MessageBody' => json_encode($this->message)
]);

return TRUE;

}

/**
* Get a message via SQS.
*/
function get()
{

$result = $this->sqs_client->ReceiveMessage([
'QueueUrl' => 'https://sqs.us-east-1.amazonaws.com/947603853016/rs-video-harvester.fifo'
]);

return TRUE;

}

/**
* Delete a message from SQS.
*/
function delete()
{

$this->sqs_client->DeleteMessage([
'QueueUrl' => 'https://sqs.us-east-1.amazonaws.com/947603853016/rs-video-harvester.fifo',
'ReceiptHandle' => $message['ReceiptHandle']
]);

return TRUE;

}

}

0 comments on commit d611335

Please sign in to comment.