Exemplo n.º 1
0
$details = $flipkart->call_url($dotd_url);
if (!$details) {
    echo 'Error: Could not retrieve products list.';
    exit;
}
//The response is expected to be JSON. Decode it into associative arrays.
$details = json_decode($details, TRUE);
$products = $details['productInfoList'];
echo "<table border=2 cellpadding=10 cellspacing=1 style='text-align:center'>";
$count = 0;
$end = 1;
$i = 1;
try {
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'in', AWS_ASSOCIATE_TAG);
    $amazonEcs->associateTag(AWS_ASSOCIATE_TAG);
    $response = $amazonEcs->country('in')->category('All')->search($query);
    //Make sure there are products in the list.
    if (count($products) > 0) {
        foreach ($products as $product) {
            //Hide out-of-stock items unless requested.
            if ($count % 2 == 0) {
                $inStock = $product['productBaseInfo']['productAttributes']['inStock'];
                if (!$inStock) {
                    continue;
                }
                //Keep count.
                //The API returns these values nested inside the array.
                //Only image, price, url and title are used in this demo
                $productId = $product['productBaseInfo']['productIdentifier']['productId'];
                $title = $product['productBaseInfo']['productAttributes']['title'];
                $productDescription = $product['productBaseInfo']['productAttributes']['productDescription'];
 // changing the category to DVD and the response to only images and looking for some matrix stuff.
 $response = $amazonEcs->category('DVD')->responseGroup('Large')->search("Matrix Revolutions");
 //var_dump($response);
 // from now on you want to have pure arrays as response
 $amazonEcs->returnType(AmazonECS::RETURN_TYPE_ARRAY);
 // searching again
 $response = $amazonEcs->search('Bud Spencer');
 //var_dump($response);
 // and again... Changing the responsegroup and category before
 $response = $amazonEcs->responseGroup('Small')->category('Books')->search('PHP 5');
 //var_dump($response);
 // category has been set so lets have a look for another book
 $response = $amazonEcs->search('MySql');
 //var_dump($response);
 // want to look in the US Database? No Problem
 $response = $amazonEcs->country('com')->search('MySql');
 //var_dump($response);
 // or Japan?
 $response = $amazonEcs->country('co.jp')->search('MySql');
 //var_dump($response);
 // Back to DE and looking for some Music !! Warning "Large" produces a lot of Response
 $response = $amazonEcs->country('de')->category('Music')->responseGroup('Small')->search('The Beatles');
 //var_dump($response);
 // Or doing searchs in a loop?
 for ($i = 1; $i < 4; $i++) {
     $response = $amazonEcs->search('Matrix ' . $i);
     //var_dump($response);
 }
 // Want to have more Repsonsegroups?                         And Maybe you want to start with resultpage 2?
 $response = $amazonEcs->responseGroup('Small,Images')->optionalParameters(array('ItemPage' => 2))->search('Bruce Willis');
 //var_dump($response);
 // changing the category to DVD and the response to only images and looking for some matrix stuff.
 $response = $amazonEcs->category('DVD')->responseGroup('Images')->search("Matrix Revolutions");
 //var_dump($response);
 // from now on you want to have pure arrays as response
 $amazonEcs->returnType(AmazonECS::RETURN_TYPE_ARRAY);
 // searching again
 $response = $amazonEcs->search('Bud Spencer');
 //var_dump($response);
 // and again... Changing the responsegroup and category before
 $response = $amazonEcs->responseGroup('Small')->category('Books')->search('PHP 5');
 //var_dump($response);
 // category has been set so lets have a look for another book
 $response = $amazonEcs->search('MySql');
 //var_dump($response);
 // want to look in the US Database? No Problem
 $response = $amazonEcs->country('us')->search('MySql');
 //var_dump($response);
 // or Japan?
 $response = $amazonEcs->country('jp')->search('MySql');
 //var_dump($response);
 // Back to DE and looking for some Music !! Warning "Large" produces a lot of Response
 $response = $amazonEcs->country('de')->category('Music')->responseGroup('Large')->search('The Beatles');
 //var_dump($response);
 // Or doing searchs in a loop?
 for ($i = 1; $i < 4; $i++) {
     $response = $amazonEcs->search('Matrix ' . $i);
     //var_dump($response);
 }
 // Want to have more Repsonsegroups?                         And Maybe you want to start with resultpage 2?
 $response = $amazonEcs->responseGroup('Small,Images')->optionalParameters(array('ItemPage' => 2))->search('Bruce Willis');
 //var_dump($response);