우리는 쉽게 Amazon-ECS-PHP-Library 을 사용하여 고객 리뷰를 얻을 수 있습니다.이 클래스를 사용하면 앱이 ISBN 번호를 기반으로 리뷰가있는 Amazon 페이지의 URL을 생성합니다.
코드
# see comment above about 10 and 13 digit ISBNs
if($reviews = getAmazonReviews($book['ISBN_10']))
{
$amazonReviewsIframe = $reviews;
}
else
{
$asin = isbnToAsin($book['ISBN_13']);
$amazonReviewsIframe = getAmazonReviews($asin);
}
if($amazonReviewsIframe)
{
echo "<a class='fboxEdit' href='$amazonReviewsIframe'>Amazon</a>";
}
# get the first two values from the Product Advertising API,
# last 2 values are needed for Amazon-ECS-PHP-Library
define("API_KEY", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
define("API_SECRET", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
define("COUNTRY_CODE", "com");
define("ASSOC_TAG", "myrealis");
function amazonApi()
{
# https://github.com/Exeu/Amazon-ECS-PHP-Library/blob/master/lib/AmazonECS.class.php
require_once 'AmazonECS.class.php';
$client = new AmazonECS(API_KEY, API_SECRET, COUNTRY_CODE, ASSOC_TAG);
return $client;
}
function getAmazonReviews($asin)
{
$client = amazonApi();
$response = $client->category('Books')->responseGroup('Reviews')->search($asin);
if($response->Items->Item->ASIN == $asin)
{
return $response->Items->Item->CustomerReviews->IFrameURL;
}
else
{
return False;
}
}
function isbnToAsin($isbn)
{
$client = amazonApi();
# I extended the AmazonECS.class with the "lookupIsbn" function
$response = $client->category('Books')->lookupIsbn($isbn);
if(isset($response->Items->Item->ASIN)) {
return $response->Items->Item->ASIN;
} else {
return False;
}
}
# added inside the AmazonECS.class
public function lookupIsbn($isbn)
{
$params = $this->buildRequestParams('ItemLookup', array(
'ItemId' => $isbn, 'IdType' => 'ISBN', 'SearchIndex' => 'Books'
));
return $this->returnData(
$this->performSoapRequest("ItemLookup", $params)
);
}
자세한 내용은이 링크를 확인하시기 바랍니다 .. Show Amazon book reviews on your site with the Product Advertising API
http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html – P0ZiTR0N