I use clusterdev.flipkart-api and from this api I got the name and link of the flipkart directory, then click on it. I get access to directories. But I need to get the specific price of the product, the title, the data in theStock from this api. I tried to make some changes, but I have no more knowledge in json, so I can not get the details. After receiving a certain product price, title, information in the store, I must update it in my database.
Flipkart Api FAQ Link: http://www.flipkart.com/affiliate/apifaq
Please tell me what changes I need to make in order to get the product price, name, installation and other details.
Actual code: https://github.com/xaneem/flipkart-api-php
Included file: https://github.com/xaneem/flipkart-api-php/blob/master/clusterdev.flipkart-api.php
Code here
<?php
include "clusterdev.flipkart-api.php";
$flipkart = new \clusterdev\Flipkart("pratikson3", "853d3bc027514b3aa33f1caa4f30f1cf", "json");
$url = isset($_GET['url'])?$_GET['url']:false;
if($url){
$url = base64_decode($url);
$hidden = isset($_GET['hidden'])?false:true;
$details = $flipkart->call_url($url);
if(!$details){
echo 'Error: Could not retrieve products list.';
exit();
}
$details = json_decode($details, TRUE);
$nextUrl = $details['nextUrl'];
$validTill = $details['validTill'];
$products = $details['productInfoList'];
echo "<table border=2 cellpadding=10 cellspacing=1 style='text-align:center'>";
$count = 0;
$end = 1;
if(count($products) > 0){
foreach ($products as $product) {
$inStock = $product['productBaseInfo']['productAttributes']['inStock'];
if(!$inStock && $hidden)
continue;
$count++;
$productId = $product['productBaseInfo']['productIdentifier']['productId'];
$title = $product['productBaseInfo']['productAttributes']['title'];
$productDescription = $product['productBaseInfo']['productAttributes']['productDescription'];
$productImage = array_key_exists('200x200', $product['productBaseInfo']['productAttributes']['imageUrls'])?$product['productBaseInfo']['productAttributes']['imageUrls']['200x200']:'';
$sellingPrice = $product['productBaseInfo']['productAttributes']['sellingPrice']['amount'];
$productUrl = $product['productBaseInfo']['productAttributes']['productUrl'];
$productBrand = $product['productBaseInfo']['productAttributes']['productBrand'];
$color = $product['productBaseInfo']['productAttributes']['color'];
$productUrl = $product['productBaseInfo']['productAttributes']['productUrl'];
$end = 0;
if($count%3==1)
echo '<tr><td>';
else if($count%3==2)
echo '</td><td>';
else{
echo '</td><td>';
$end =1;
}
echo '<a target="_blank" href="'.$productUrl.'"><img src="'.$productImage.'"/><br>'.$title."</a><br>Rs. ".$sellingPrice;
if($end)
echo '</td></tr>';
}
}
if($count==0){
echo '<tr><td>The retrieved products are not in stock. Try the Next button or another category.</td><tr>';
}
if($end!=1)
echo '</td></tr>';
echo '</table>';
echo '<h2><a href="?url='.base64_encode($nextUrl).'">NEXT >></a></h2>';
exit();
}
$home = $flipkart->api_home();
if($home==false){
echo 'Error: Could not retrieve API homepage';
exit();
}
$home = json_decode($home, TRUE);
$list = $home['apiGroups']['affiliate']['apiListings'];
echo '<table border=2 style="text-align:center;">';
$count = 0;
$end = 1;
foreach ($list as $key => $data) {
$count++;
$end = 0;
if($count%3==1)
echo '<tr><td>';
else if($count%3==2)
echo '</td><td>';
else{
echo '</td><td>';
$end =1;
}
echo "<strong>".$key."</strong>";
echo "<br>";
echo '<a href="?url='.base64_encode($data['availableVariants']['v0.1.0']['get']).'">View Products »</a>';
}
if($end!=1)
echo '</td></tr>';
echo '</table>';
source
share