Example #1
1
<html lang="en">
<head>
	</head>
	<body>
<?php 
//Include the class.
include "smartpatron.flipkart-api.php";
include "smartpatron.snapdeal-api.php";
//Replace <affiliate-id> and <access-token> with the correct values
$flipkart = new \smartpatron\Flipkart("jagruthna", "26bb396c35104c8d9af52eed52dff001", "json");
$snapdeal = new \smartpatron\Snapdeal("83205", "f81560e63662d37d7e460b94dd65ac", "json");
//If the control reaches here, the API directory view is shown.
//Query the API
$home = $flipkart->api_home();
//Make sure there is a response.
if ($home == false) {
    echo 'Error: Could not retrieve API homepage';
    exit;
}
//Convert into associative arrays.
$home = json_decode($home, TRUE);
$list = $home['apiGroups']['affiliate']['apiListings'];
//Create the tabulated view for different categories.
echo "<center><table  width='100%' style='text-align:left;'>";
$count = 0;
$a = 0;
foreach ($list as $key => $data) {
    $key1 = str_replace('_', ' ', $key);
    //URL is base64 encoded when sent in query string.
    $URL[$a] = base64_encode($data['availableVariants']['v0.1.0']['get']);
    $cat[$a] = $key1;
Example #2
0
	 <link href="ddmenu/ddmenu.css" rel="stylesheet" type="text/css" />
	   <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
   <script>
   $("td").each(function() {
    if ($(this).html() == '') {
        $(this).remove();
    }
  }</script>
  <link href='http://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>
	</head>
	<body background='bl.png'>
<?php 
include "header.php";
$flipkart = new \smartpatron\Flipkart("jagruthna", "26bb396c35104c8d9af52eed52dff001", "json");
$snapdeal = new \smartpatron\Snapdeal("83205", "f81560e63662d37d7e460b94dd65ac", "json");
//To view category pages, API URL is passed as query string.
$url = isset($_GET['url']) ? $_GET['url'] : false;
if ($url) {
    //URL is base64 encoded to prevent errors in some server setups.
    $url = base64_decode($url);
    //This parameter lets users allow out-of-stock items to be displayed.
    $hidden = isset($_GET['hidden']) ? false : true;
    //Call the API using the URL.
    $details = $flipkart->call_url($url);
    if (!$details) {
        echo 'Error: Could not retrieve products list.';
        exit;
    }
    //The response is expected to be JSON. Decode it into associative arrays.