Example #1
0
// User Config
//------------------------------------
$associate_id = '';
$developer_token = '';
//------------------------------------
if (!empty($_GET['keyword'])) {
    if (isset($_GET['p'])) {
        $page = $_GET['p'];
    } else {
        $page = '1';
    }
    $soap = new SoapClient("http://soap.amazon.co.jp/schemas3/AmazonWebServices.wsdl");
    $keyword = mb_convert_encoding($_GET['keyword'], "UTF-8", "auto");
    $param = array('keyword' => $keyword, 'mode' => 'books-jp', 'locale' => 'jp', 'sort' => '+salesrank', 'type' => 'lite', 'page' => $page, 'tag' => $associate_id, 'devtag' => $developer_token);
    // Request & Result
    $result = $soap->KeywordSearchRequest($param);
    mb_convert_variables("UTF-8", "auto", $result);
    $result_message = '「<span class="highlight">' . $keyword . '</span>」で検索、' . $result->TotalResults . '件がヒットしました。';
    // Pager
    $pager = '';
    $page_max = ceil($result->TotalResults / 10);
    for ($i = 0; $i < $page_max; $i++) {
        $current = $i + 1;
        if ($page == $current) {
            $pager .= '<strong>' . $current . '</strong>';
        } else {
            $pager .= '<a href="' . $_SERVER['PHP_SELF'] . '?keyword=' . urlencode($keyword) . '&amp;p=' . $current . '">' . $current . '</a>';
        }
    }
    // Initialize the item information
    $detail_url = '';