これは私のエラーです:
1 列目の 2 行目のエラー: ドキュメントの末尾に余分なコンテンツがあります
以下は、最初のエラーまでのページのレンダリングです。
hereからコードをコピーしました。
これが私のコードです:
<?php
header('Content-type: text/xml');
function awsRequest($searchIndex, $keywords, $responseGroup = false, $operation = "ItemSearch", $pageNumber = 1){
$service_url = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService";
$associate_tag = "your-associate-tag";
$secret_key = "YOUR_SECRET_KEY";
$access_key = "YOUR_ACCESS_KEY";
// build initial request uri
$request = "$service_url&Operation=$operation&AssociateTag=$associate_tag&SearchIndex=$searchIndex&Keywords=".urlencode($keywords)."&ItemPage=$pageNumber";
// parse request into params
$uri_elements = parse_url($request);
$request = $uri_elements['query'];
parse_str($request, $parameters);
// add new params
$parameters['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z");
$parameters['Version'] = $version;
$parameters['AWSAccessKeyId'] = $access_key;
if($responseGroup){
$parameters['ResponseGroup'] = $responseGroup;
}
ksort($parameters);
// encode params and values
foreach($parameters as $parameter => $value){
$parameter = str_replace("%7E", "~", rawurlencode($parameter));
$value = str_replace("%7E", "~", rawurlencode($value));
$request_array[] = $parameter . '=' . $value;
}
$new_request = implode('&', $request_array);
// make it happen
$signature_string = "GET\n{$uri_elements['host']}\n{$uri_elements['path']}\n{$new_request}";
$signature = urlencode(base64_encode(hash_hmac('sha256', $signature_string, $secret_key, true)));
// return signed request uri
return "http://{$uri_elements['host']}{$uri_elements['path']}?{$new_request}&Signature={$signature}";
}
// make the request
$xml = simplexml_load_file(awsRequest("VideoGames", "call of duty", "Images", "ItemSearch", "1"));
// now retrieve some data
$totalPages = $xml->Items->TotalPages;
echo "<p>There are $totalPages pages in the XML results.</p>";
// retrieve data in a loop
echo "<ul>\n";
foreach($xml->Items->Item as $item){
echo "<li>".$item->ASIN."</li>\n";
}
echo "</ul>\n";
?>
これをAWSにデプロイしています。