Skip to content

Instantly share code, notes, and snippets.

@DustyReagan
Created September 14, 2014 07:56
Show Gist options
  • Save DustyReagan/acd99e2d9e4c103586fe to your computer and use it in GitHub Desktop.
Save DustyReagan/acd99e2d9e4c103586fe to your computer and use it in GitHub Desktop.
Rackspace Queue API
<?php
include_once(APPLICATION_PATH . '/../library/vendor/autoload.php');
use OpenCloud\Rackspace;
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => 'myusername',
'apiKey' => 'myapikey'
));
$service = $client->queuesService('cloudQueues', 'DFW');
$queue = $service->getQueue('FoF');
$stats = $queue->getStats();
print_r($stats);
use OpenCloud\Common\Constants\Datetime;
$messages = array(
array(
'body' => (object) ['property' => 'Here we go'],
'ttl' => 2 * Datetime::DAY
)
);
$response = $queue->createMessages($messages);
@DustyReagan
Copy link
Author

Produces:

stdClass Object ( [claimed] => 0 [total] => 0 [free] => 0 )
Fatal error: Uncaught exception 'Guzzle\Http\Exception\ClientErrorResponseException' with message 'Client error response [status code] 400 [reason phrase] Bad Request [url] https://dfw.queues.api.rackspacecloud.com/v1/404082/queues/FoF/messages' in /var/sites/FriendOrFollowDusty/library/vendor/guzzle/http/Guzzle/Http/Exception/BadResponseException.php:43 Stack trace: #0 /var/sites/FriendOrFollowDusty/library/vendor/guzzle/http/Guzzle/Http/Message/Request.php(145): Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response)) #1 [internal function]: Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher)) #2 /var/sites/FriendOrFollowDusty/library/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispa in /var/sites/FriendOrFollowDusty/library/vendor/guzzle/http/Guzzle/Http/Exception/BadResponseException.php on line 43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment