Exemplo n.º 1
0
<?php

include "../../lib/v1/src/dawanda.php";
$api = new DaWandaAPI("380d7924396f5596116f3d8815c97dfd8c975582", "de");
// empty variables
$error = "";
$category_content = "";
$product_content = "";
$current_page = 1;
$max_page = 1;
// empty variables - end
if ($_GET["username"]) {
    try {
        $shop_details = $api->getShopDetails($_GET["username"]);
        foreach ($shop_details->result->shop->shop_categories as $shop_category) {
            $category_content .= "<li><a href='show.php?username="******"username"] . "&shop_cat=" . $shop_category->id . "'>" . $shop_category->name . "</a></li>";
        }
        $current_page = isset($_GET["page"]) ? $_GET["page"] : 1;
        $shop_category = isset($_GET["shop_cat"]) ? $_GET["shop_cat"] : $shop_details->result->shop->shop_categories[0]->id;
        $products = $api->getProductsForShopCategory($shop_category, array("page" => $current_page));
        $max_page = $products->pages;
        if (count($products->result->products) == 0) {
            $product_content .= "<li>No products in this category.</li>";
        } else {
            foreach ($products->result->products as $product) {
                $product_content .= "<li>" . "<a href='" . $api->getHost() . "/product/{$product->id}' target='_blank'>" . "<img border='0' src='" . $product->default_image->listview . "'>" . "</a>" . "<span>" . substr($product->name, 0, 25) . (strlen($product->name) > 25 ? "..." : "") . "</span>" . "<div style='clear:both'></div>" . "<span>" . substr($product->user->name, 0, 20) . (strlen($product->name) > 20 ? "..." : "") . "</span>" . "<span style='float:right'>" . $product->price->cents / 100 . " " . $product->price->currency_code . "</span>" . "</li>";
            }
        }
    } catch (Exception $e) {
        $error = "Username is invalid!";
    }
Exemplo n.º 2
0
<?php

include "../../lib/v1/src/dawanda.php";
$api = new DaWandaAPI("380d7924396f5596116f3d8815c97dfd8c975582", "de");
if ($_GET["username"]) {
    $firstPuzzle = null;
    $error = null;
    $products = null;
    try {
        $products = $api->getProductsForShop($_GET["username"], array("per_page" => 7));
    } catch (Exception $e) {
        $error = "Username is invalid!";
    }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <title>DaWanda API: PHP Framework</title>
  <script type="text/javascript" charset="utf-8" src="lib/jquery.js"></script>
  <script type="text/javascript" src="lib/jquery.puzzle.js"></script>
  <script type="text/javascript">
    function changePuzzle(source) {
      var src = source.replace("thumb", "big");
      var img = new Image();
      img.src = src;
      
      img.onload = function() {
        $("#puzzle").empty();
        $("#puzzle").append('<img src="'+ src +'" width="'+img.width+'" height="'+img.height+'" />');