Ebay API - Abfrage von beendeten Auktionen

ICPUI

Mitglied
HI all
Ich bin gerade an einem kleinen Ebay-Script. Jetzt hab ich bereits ein kleines Script, welches die Verkäuferdaten sowie seine Auktionen auflistet. Jedoch nur die Aktiven. Ich möchte jedoch alle bereits beendeten Auktionen. Wie mache ich das? Kann mir da jemand helfen?

Hier der Code bis jetzt:

PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<?php

$_POST['SellerID'] = "domainpromotions";
$_POST['ItemType'] = "AllItemTypes";
$_POST['ItemSort'] = "EndTime";
$_POST['Debug'] = "0";

function getPrettyTimeFromEbayTime($eBayTimeString){
    // Input is of form 'PT12M25S'
    $matchAry = array(); // initialize array which will be filled in preg_match
    $pattern = "#P([0-9]{0,3}D)?T([0-9]?[0-9]H)?([0-9]?[0-9]M)?([0-9]?[0-9]S)#msiU";
    preg_match($pattern, $eBayTimeString, $matchAry);
    
    $days  = (int) $matchAry[1];
    $hours = (int) $matchAry[2];
    $min   = (int) $matchAry[3];    // $matchAry[3] is of form 55M - cast to int 
    $sec   = (int) $matchAry[4];
    
    $retnStr = '';
    if ($days)  { $retnStr .= "$days day"    . pluralS($days);  }
    if ($hours) { $retnStr .= " $hours hour" . pluralS($hours); }
    if ($min)   { $retnStr .= " $min minute" . pluralS($min);   }
    if ($sec)   { $retnStr .= " $sec second" . pluralS($sec);   }
    
    return $retnStr;
} // function

function pluralS($intIn) {
    // if $intIn > 1 return an 's', else return null string
    if ($intIn > 1) {
        return 's';
    } else {
        return '';
    }
} // function


//error_reporting(E_ALL);  // turn on all errors, warnings and notices for easier debugging

if(isset($_POST['SellerID']))
{
    $endpoint = 'http://open.api.ebay.com/shopping';  // URL to call
    $responseEncoding = 'XML';   // Format of the response 
    $version = '537';   // API version number
    $appID   = 'SaschaAn-dfbb-40ce-9e63-66d8622956fd';   // replace this with your AppID
    
    $debug   = true;
    $debug = (boolean) $_POST['Debug']; 

    $sellerID  = urlencode($_POST['SellerID']);   // cleanse input
    $siteID    = urlencode("77");  

    $pageResults = '';
    $pageResults .= getUserProfileResultsAsHTML($sellerID);
    $pageResults .= getFindItemsAdvancedResultsAsHTML($sellerID);

} // if    

function getUserProfileResultsAsHTML($sellerID) {
    global $siteID, $endpoint, $responseEncoding, $version, $appID, $debug;
    $results = '';
    
    $apicall = "$endpoint?callname=GetUserProfile"
             . "&version=$version"
             . "&siteid=$siteID"
             . "&appid=$appID"
             . "&UserID=$sellerID"
             . "&IncludeSelector=Details,FeedbackHistory"   // need Details to get MyWorld info
             . "&responseencoding=$responseEncoding";
             
    if ($debug) { print "<br />GetUserProfile call = <blockquote>$apicall </blockquote>"; }
    
    // Load the call and capture the document returned by the Shopping API
    $resp = simplexml_load_file($apicall);
    
    if ($resp) {
        if (!empty($resp->User->MyWorldLargeImage)) {
            $myWorldImgURL = $resp->User->MyWorldLargeImage;
        } else {
            $myWorldImgURL = 'http://pics.ebaystatic.com/aw/pics/community/myWorld/imgBuddyBig1.gif';            
        }
        $results .= "<table><tr>\n";
        $results .= "<td><a href=\"" . $resp->User->MyWorldURL . "\"><img src=\"" 
                  . $myWorldImgURL . "\"></a></td>\n";
        $results .= "<td>Seller : $sellerID <br /> \n";
        $results .= "Feedback score : " . $resp->User->FeedbackScore . "<br />\n";
        $posCount = $resp->FeedbackHistory->UniquePositiveFeedbackCount;
        $negCount = $resp->FeedbackHistory->UniqueNegativeFeedbackCount;
        $posFeedBackPct = sprintf("%01.1f", (100 * ($posCount / ($posCount + $negCount))));
        $results .= "Positive feedback : $posFeedBackPct%<br />\n";
        $regDate = substr($resp->User->RegistrationDate, 0, 10);
        $results .= "Registration date : $regDate<br />\n";
        
        $results .= "</tr></table>\n";
                  
    } else {
        $results = "<h3>No user profile for seller $sellerID";
    }
    return $results;
} // function

function getFindItemsAdvancedResultsAsHTML($sellerID) {
    global $siteID, $endpoint, $responseEncoding, $version, $appID, $debug;
    
    $maxEntries = 100;
    
    $itemType  = urlencode($_POST['ItemType']);
    $itemSort  = urlencode($_POST['ItemSort']);
    
    $results = '';   // local to this function
    // Construct the FindItems call 
    $apicall = "$endpoint?callname=FindItemsAdvanced"
             . "&version=$version"
             . "&siteid=$siteID"
             . "&appid=$appID"   
             . "&SellerID=$sellerID"
             . "&MaxEntries=$maxEntries"
             . "&ItemSort=$itemSort"
             . "&ItemType=$itemType"
             . ""
             . "&IncludeSelector=SearchDetails" 
             . "&ListingStatus=ended"            
             . "&trackingpartnercode=1"              // fill in your information in next 3 lines
             . "&trackingid=123"
             . "&affiliateuserid=456"
             . "&responseencoding=$responseEncoding";
             
    if ($debug) { print "<br />FindItemsAdvanced call = <blockquote>$apicall </blockquote>"; }
    
    // Load the call and capture the document returned by the Shopping API
    $resp = simplexml_load_file($apicall);
    
    // Check to see if the response was loaded, else print an error
    if ($resp->SearchResult->ItemArray) {
        $results .= 'Total items : ' . $resp->TotalItems . "<br />\n";
        $results .= '<table id="example" class="tablesorter" border="0" cellpadding="0" cellspacing="1">' . "\n";
        $results .= "<thead><tr><th /><th>Title</th><th>Price     </th><th>Shipping     </th><th>Total     </th><th><!--Currency--></th><th>Time Left</th><th>End Time</th></tr></thead>\n";
        
        // If the response was loaded, parse it and build links  
        foreach($resp->SearchResult->ItemArray->Item as $item) {
        
        	print_r($item);
        	echo '<br><br>';
        	
            if ($item->GalleryURL) {
                $picURL = $item->GalleryURL;
            } else {
                $picURL = "http://pics.ebaystatic.com/aw/pics/express/icons/iconPlaceholder_96x96.gif";
            }
            $link  = $item->ViewItemURLForNaturalSearch;
            $title = $item->Title;
            
            $price = sprintf("%01.2f", $item->ConvertedCurrentPrice);
            $ship  = sprintf("%01.2f", $item->ShippingCostSummary->ShippingServiceCost);
            $total = sprintf("%01.2f", ((float)$item->ConvertedCurrentPrice 
                                      + (float)$item->ShippingCostSummary->ShippingServiceCost));
            
            // Determine currency to display - so far only seen cases where priceCurr = shipCurr, but may be others
            $priceCurr = (string) $item->ConvertedCurrentPrice['currencyID'];
            $shipCurr  = (string) $item->ShippingCostSummary->ShippingServiceCost['currencyID'];
            if ($priceCurr == $shipCurr) {
                $curr = $priceCurr;
            } else {
                $curr = "$priceCurr / $shipCurr";  // potential case where price/ship currencies differ
            }

            $timeLeft = getPrettyTimeFromEbayTime($item->TimeLeft);
            $endTime = strtotime($item->EndTime);   // returns Epoch seconds
            $endTime = $item->EndTime;
               
            $results .= "<tr><td><a href=\"$link\"><img src=\"$picURL\"></a></td><td><a href=\"$link\">$title ($item->ItemID)</a></td>"
                     .  "<td>$price</td><td>$ship</td><td>$total</td><td>$curr</td><td>$timeLeft</td><td><nobr>$endTime</nobr></td></tr>";
        }
        $results .= "</table>";
    }
    // If there was no search response, print an error
    else {
        $results = "<h3>No items found matching the $itemType type.";
    }  // if resp
    
    return $results;
    
}  // function

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>GetUserProfile</title>
<script src="./js/jQuery.js"></script>
<script src="./js/jQueryUI/ui.tablesorter.js"></script>

<script>
    $(document).ready(function() { 
        $("table").tablesorter({ 
            sortList:[[7,0],[4,0]],      // upon screen load, sort by col 7, 4 ascending (0)
            debug: false,                // if true, useful for debugging, e.g. debugging item sorting
            headers: { 
                0: { sorter: false },    // col 0 = first = left most column - no sorting
                5: { sorter: false }, 
                6: { sorter: false },
                7: { sorter: 'text'}     // specify text sorter, otherwise mistakenly takes shortDate parser
            } 
        }); 
    });
</script>
  
</head>

<body>


<link rel="stylesheet" href="./css/flora.all.css" type="text/css" media="screen" title="Flora (Default)">


<?php 
    print $pageResults;
    $allItemsURL = "http://search.ebay.com/_W0QQsassZ" . $sellerID;
    print "<p><a href=\"$allItemsURL\">See all items from this seller</a></p>";
?>

</body>
</html>
 
Kann mir gut vorstellen, dass es dafür auch eine Schittstelle gibt. Sonst lese doch einfach das Datum aus, wann die Auktion gestartet ist und addiere dazu die Gesamtlaufzeit der Auktion hinzu und ziehe das ganze von dem aktuellen Timestamp ab. Ist das Ergebnis größer 0, ist die Auktion beendet.
MfG, Andy
 
Natürlich gibts ne Schnittstelle die benutze ich ja. Aber ich weiss nicht welche Variablen ich nehmen muss damit abgelaufene Auktionen sichtbar sind. Und das mit der Zeit funktioniert iwie ned.
 
Zurück