예제 #1
0
                foreach ($value as $j => $content) {
                    // Index the key for each value
                    $urlfilter .= "&itemFilter({$i}).{$key}({$j})={$content}";
                }
            } else {
                if ($value != "") {
                    $urlfilter .= "&itemFilter({$i}).{$key}={$value}";
                }
            }
        }
        $i++;
    }
    return "{$urlfilter}";
}
// End of buildURLArray function
buildURLArray($filterarray);
// Construct the findItemsByKeywords HTTP GET call
$apicall = "{$endpoint}?";
$apicall .= "OPERATION-NAME=findItemsByKeywords";
$apicall .= "&SERVICE-VERSION={$version}";
$apicall .= "&SECURITY-APPNAME={$appid}";
$apicall .= "&GLOBAL-ID={$globalid}";
$apicall .= "&keywords={$safequery}";
$apicall .= "&paginationInput.entriesPerPage=25";
$apicall .= "{$urlfilter}";
// Load the call and capture the document returned by eBay API
$resp = simplexml_load_file($apicall);
$currentDate = date("Y/m/d");
// Check to see if the request was successful, else print an error
if ($resp->ack == "Success") {
    $results = "<table cellpadding='10'>";
예제 #2
0
        ///my own
        $unformattedmoney = (double) $item->sellingStatus->currentPrice;
        $price = money_format('$%i', $unformattedmoney);
        // For each SearchResultItem node, build a link and append it to $results
        $results .= "<tr><td><img src=\"{$pic}\"></td><td><a href=\"{$link}\">{$title}</a></td><td style=\"text-align: right; margin-right: 10px;\">{$price}</td></tr>";
    }
} elseif ($query == null || $query == "") {
    $results = "Please enter a valid query.";
} else {
    $results = "<h3>Oops! The request was not successful. Make sure you are using a valid ";
    $results .= "AppID for the Production environment.</h3>";
}
// Create a PHP array of the item filters you want to use in your request
$filterarray = array(array('name' => 'MaxPrice', 'value' => '25', 'paramName' => 'Currency', 'paramValue' => 'USD'), array('name' => 'FreeShippingOnly', 'value' => 'true', 'paramName' => '', 'paramValue' => ''), array('name' => 'ListingType', 'value' => array('AuctionWithBIN', 'FixedPrice'), 'paramName' => '', 'paramValue' => ''));
////////////////////////////////////////////////////////////////////////////////////////////
$urlfilter = buildURLArray($filterarray);
$apicall .= "{$urlfilter}";
////////////////////////////////////////////////////////////////////////////////////////////
// Generates an indexed URL snippet from the array of item filters
function buildURLArray($filterarray)
{
    global $urlfilter;
    global $i;
    // Iterate through each filter in the array
    foreach ($filterarray as $itemfilter) {
        // Iterate through each key in the filter
        foreach ($itemfilter as $key => $value) {
            if (is_array($value)) {
                foreach ($value as $j => $content) {
                    // Index the key for each value
                    $urlfilter .= "&itemFilter({$i}).{$key}({$j})={$content}";