topical media & game development

talk show tell print

server-webapi-code-09-personalBrowser.php / php



  <html>
  <head>
  <title>Personal eBay Navigator</title>
  <style tyle="text/css">
  div.topbar
  {
    width: 100%;
    font-family: verdana;
    border: thin solid black;
    align: left;
  }
  span.mainTitle
  {
    font-weight: bold;
    font-size: 150%;
    align: right;
  }
  
  div.resultHeading
  {
    width: 100%;
    font-family: verdana;
    border: thin solid black;
    align: left;
  }
  
  .catTitle
  {
    font-weight: bold;
    text-decoration: none;
    display: block;
  }
  
  a.viewItems
  {
    font-style: italic;
    text-decoration: none;
  }
  div.itemListingEven
  {
    border: thin solid black;
    margin: 2px;
    padding: 3px;
  }
  div.itemListingOdd
  {
    border: thin solid black;
    margin: 2px;
    padding: 3px;
    background-color: EEEEFF;
  }
  </style>
  </head>
  <body>
  <div class="topbar">
    <span class="mainTitle" display="block">Personal eBay Browser</span>  <span class="searchBox"><form method="get">Perform a Search: <input type="text" name="query"><input type="submit"></form></span>
  </div>
  <?php
  error_reporting(E_ALL);
  require('eBayCaller.php');
  
  echo '';
  if (isset(_GET['loadCat']))
  {
    displayCatagoryListings(_GET['loadCat']);
  }elseif(isset(_GET['listCategory']) && ctype_digit(_GET['listCategory']))
  {
    getCategoryListings(_GET['listCategory']);
  }elseif(isset(_GET['searchcategory']))
  {
    doCategorySearch(_GET['query'], _GET['searchcategory']);
  }elseif (isset(_GET['query']))
  {
          doBasicSearch(_GET['query']);
  }else
  {
          displayCatagoryListings();
          exit;
  }
          
  function getSimpleTime()
  {
    global version, devID, appID, cert, token;
    call = "GeteBayOfficialTime";
    message = <<< XMLBLOCK
  <?xml version="1.0" encoding="utf-8"?> 
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soapenv:Header> 
      <RequesterCredentials soapenv:mustUnderstand="0" xmlns="urn:ebay:apis:eBLBaseComponents"> 
         <eBayAuthToken>token</eBayAuthToken> 
         <ns:Credentials xmlns:ns="urn:ebay:apis:eBLBaseComponents"> 
          <ns:DevId>devID</ns:DevId> 
          <ns:AppId>appID</ns:AppId> 
          <ns:AuthCert>cert</ns:AuthCert> 
         </ns:Credentials> 
      </RequesterCredentials> 
    </soapenv:Header> 
    <soapenv:Body> 
    <GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <ns1:Version xmlns:ns1="urn:ebay:apis:eBLBaseComponents">version</ns1:Version> 
    </GeteBayOfficialTimeRequest> 
    </soapenv:Body> 
  </soapenv:Envelope>
  XMLBLOCK;
    RAWxml = calleBay(call, message, TRUE);
    echo RAWxml;
    xml = simplexml_load_string(RAWxml);
    echo "<pre>";
    print_r(xml);
    
    echo "Time: " . xml->children('schemas.xmlsoap.org/soap/envelope/')->children('urn:ebay:apis:eBLBaseComponents')->GeteBayOfficialTimeResponse->Timestamp . "\n";
    nestedXML = xml->children('schemas.xmlsoap.org/soap/envelope/')->children('urn:ebay:apis:eBLBaseComponents');
    print_r(nestedXML);
    echo "</pre>";
  }
  
  function getTime()
  {
    call = "GeteBayOfficialTime"; 
    body = 
    '<soapenv:Body> 
    <GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <ns1:Version xmlns:ns1="urn:ebay:apis:eBLBaseComponents">425</ns1:Version> 
    </GeteBayOfficialTimeRequest> 
    </soapenv:Body>';
    message = generateRequest(body);
    echo message;
    xml =  calleBay(call, message, TRUE);
    xml = simplexml_load_string(xml);
    echo "Time: " . xml->children('schemas.xmlsoap.org/soap/envelope/')->children('urn:ebay:apis:eBLBaseComponents')->GeteBayOfficialTimeResponse->Timestamp . "\n";
  } 
  
  function newGetTime()
  {
          call = "GeteBayOfficialTime";
          queryInfo = array();
          queryInfo["Version"] = 425;
          myRequest = generateBody(call, queryInfo);
          message = generateRequest(myRequest);
          xml =  calleBay(call, message, FALSE);
          echo "In eBay World the time is: " . xml->GeteBayOfficialTimeResponse->Timestamp . "\n";
  }
  
  function doBasicSearch(query)
  {
    call = "GetSearchResults";
    attributes = array();
    attributes['Version'] = 425;
    attributes['Query'] = query;
    myRequest = generateBody(call, attributes);
    message = generateRequest(myRequest);
    xml =  calleBay(call, message, FALSE);
    echo "<div class=\"resultHeading\">";
    echo "<span class=\"resultHeader\">Search Results for: query</span>";
    echo "</div>";
    if (xml->GetSearchResultsResponse->PaginationResult->TotalNumberOfEntries == 0)
    {
      echo "Sorry, there are no results to display";
    }else
    {
      results = array();
      foreach(xml->GetSearchResultsResponse->SearchResultItemArray->SearchResultItem AS searchResult)
      {
        results[] = searchResult->Item;
      }
      displayItems(results);
    }
  }
  
  function doCategorySearch(query, category)
  {
    call = "GetSearchResults";
    attributes = array();
    attributes['Version'] = 425;
    attributes['Query'] = query;
    attributes['CategoryID'] = category;
    myRequest = generateBody(call, attributes);
    message = generateRequest(myRequest);
    xml =  calleBay(call, message, FALSE);
    echo "<div class=\"resultHeading\">";
    echo "<span class=\"resultHeader\">Search Results for: query</span>";
    echo "</div>";
    if (xml->GetSearchResultsResponse->PaginationResult->TotalNumberOfEntries == 0)
    {
      echo "Sorry, there are no results to display,