Sample code for 30+ languages & platforms
Objective-C

SQS List Queues

See more Amazon SQS Examples

Returns a list of your Amazon SQS queues. The maximum number of queues that can be returned is 1000. If you specify a value for the optional QueueNamePrefix query parameter, only queues with a name beginning with the specified value are returned.

Chilkat Objective-C Downloads

Objective-C
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <NSString.h>
#import <CkoXml.h>

BOOL success = NO;

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

CkoRest *rest = [[CkoRest alloc] init];

//  Connect to the Amazon AWS REST server.
//  such as https://sqs.us-west-2.amazonaws.com/
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"sqs.us-west-2.amazonaws.com" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];

//  Provide AWS credentials for the REST call.
CkoAuthAws *authAws = [[CkoAuthAws alloc] init];
authAws.AccessKey = @"AWS_ACCESS_KEY";
authAws.SecretKey = @"AWS_SECRET_KEY";
//  the region should match our URL above..
authAws.Region = @"us-west-2";
authAws.ServiceName = @"sqs";

[rest SetAuthAws: authAws];

[rest AddQueryParam: @"Action" value: @"ListQueues"];
//  List only queues having a name starting with "c".
//  Comment out this line to list all queues.
[rest AddQueryParam: @"QueueNamePrefix" value: @"c"];

NSString *responseXml = [rest FullRequestNoBody: @"GET" uriPath: @"/"];
if (rest.LastMethodSuccess != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

//  A successful response will have a status code equal to 200.
if ([rest.ResponseStatusCode intValue] != 200) {
    NSLog(@"%@%d",@"response status code = ",[rest.ResponseStatusCode intValue]);
    NSLog(@"%@%@",@"response status text = ",rest.ResponseStatusText);
    NSLog(@"%@%@",@"response header: ",rest.ResponseHeader);
    NSLog(@"%@%@",@"response body: ",responseXml);
    return;
}

//  Examine the successful XML response.
CkoXml *xml = [[CkoXml alloc] init];
[xml LoadXml: responseXml];
NSLog(@"%@",[xml GetXml]);
NSLog(@"%@",@"----");

//  A successful response looks like this:
//  <?xml version="1.0" encoding="utf-8" ?>
//  <ListQueuesResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
//      <ListQueuesResult>
//          <QueueUrl>https://sqs.us-west-2.amazonaws.com/123491855557/chilkatTest</QueueUrl>
//          <QueueUrl>https://sqs.us-west-2.amazonaws.com/123496666627/chilkatses</QueueUrl>
//      </ListQueuesResult>
//      <ResponseMetadata>
//          <RequestId>77bce138-fbcc-5e42-9ee3-b15c1f7178c2</RequestId>
//      </ResponseMetadata>
//  </ListQueuesResponse>

//  Get each queue URL..
[xml FindChild2: @"ListQueuesResult"];
int i = 0;
int numQueues = [xml.NumChildren intValue];
while (i < numQueues) {
    NSLog(@"%@%@",@"QueueUrl: ",[xml GetChildContentByIndex: [NSNumber numberWithInt: i]]);
    i = i + 1;
}

[xml GetRoot2];