Returns the tags associated with an object. This example gets the tags for the object named "starfish.jpg" located in the bucket "chilkat100".
curl -X GET https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
<?php
$rest = new COM("Chilkat_9_5_0.Rest");
$authAws = new COM("Chilkat_9_5_0.AuthAws");
$authAws->AccessKey = 'AWS_ACCESS_KEY';
$authAws->SecretKey = 'AWS_SECRET_KEY';
$authAws->Region = 'us-east-1';
$authAws->ServiceName = 's3';
$rest->SetAuthAws($authAws);
// URL: https://chilkat100.s3.amazonaws.com/starfish.jpg?tagging
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect('chilkat100.s3.amazonaws.com',$port,$bTls,$bAutoReconnect);
if ($success != 1) {
print 'ConnectFailReason: ' . $rest->ConnectFailReason . "\n";
print $rest->LastErrorText . "\n";
exit;
}
$sbResponseBody = new COM("Chilkat_9_5_0.StringBuilder");
$success = $rest->FullRequestNoBodySb('GET','/starfish.jpg?tagging',$sbResponseBody);
if ($success != 1) {
print $rest->LastErrorText . "\n";
exit;
}
$respStatusCode = $rest->ResponseStatusCode;
if ($respStatusCode >= 400) {
print 'Response Status Code = ' . $respStatusCode . "\n";
print 'Response Header:' . "\n";
print $rest->ResponseHeader . "\n";
print 'Response Body:' . "\n";
print $sbResponseBody->getAsString() . "\n";
exit;
}
$xmlResponse = new COM("Chilkat_9_5_0.Xml");
$xmlResponse->LoadSb($sbResponseBody,1);
// See the Online Tool for Generating XML Parse Code
$Tagging_xmlns = $xmlResponse->getAttrValue('xmlns');
$i = 0;
$count_i = $xmlResponse->NumChildrenHavingTag('TagSet|Tag');
while ($i < $count_i) {
$xmlResponse->I = $i;
$Key = $xmlResponse->getChildContent('TagSet|Tag[i]|Key');
$Value = $xmlResponse->getChildContent('TagSet|Tag[i]|Value');
$i = $i + 1;
}
?>
<?xml version="1.0" encoding="UTF-8" ?>
<Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<TagSet>
<Tag>
<Key>habitat</Key>
<Value>ocean</Value>
</Tag>
<Tag>
<Key>phylum</Key>
<Value>Echinodermata</Value>
</Tag>
<Tag>
<Key>animal</Key>
<Value>starfish</Value>
</Tag>
</TagSet>
</Tagging>