/
list_more.php
50 lines (40 loc) · 1.25 KB
/
list_more.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require('include/config.php');
require('include/functions/main.php');
$keyword = $_REQUEST['query'];
$nodeID = $_REQUEST['node'];
$idx = (isset($_GET['index'])) ? $_GET['index'] : $keyword;
$page = $_REQUEST['page'];
$hash = $_REQUEST['hash'];
$keyword = str_replace(" ", "+", $keyword);
$keyword = urlencode($keyword);
$myHash = md5($keyword . $cg['private_key']);
if ($hash != $myHash) { echo ''; exit; }
$searchIndex = $idx;
if (!in_array($searchIndex, $categories)) {
$keyword .= ' ' . $searchIndex;
$searchIndex = 'All'; // reassign All
}
$operation = 'ItemSearch';
$service = 'AWSECommerceService';
$version = '2011-08-01';
$responseGroup = 'ItemAttributes,Images';
$browseNode = $nodeID;
$string_to_sign = build_request($keyword, $searchIndex, $operation, $service, $version, $responseGroup, $page, $browseNode);
$signature = get_signature($string_to_sign);
$request = $cg['amazonUrl'] . '?' . $string_to_sign;
$request .= "&Signature=".$signature;
$maxPage = ($searchIndex == 'All') ? 5 : 10;
//$response = file_get_contents($request);
$response = curl_string($request);
if ($response) {
$xml = array();
$res = simplexml_load_string($response);
//echo json_encode($res);
$obj = arrify($res->Items);
echo json_encode($obj);
} else {
echo '';
}
exit;
?>