Я знаю, что на это отвечали много раз, но я не знаю, почему я получаю эту ошибку:
Примечание: неопределенная переменная: urlfilter в / home / mjburkel / public_html / allxxcars /wp-content/plugins/insert-php/includes/shortcodes/shortcode-php.php(52): код eval () в строке 75
Я знаю, что это обычно это происходит, если переменная еще не определена, но я объявляю ее, поэтому я не совсем уверен, в чем проблема. вот мой код ... заметьте, это код php, который я вставляю в плагин сниппета Wordpress PHP ... так что, может быть, не уверен, что этот плагин вставляет какой-то странный код или неправильно его читает?
<?php /* Template Name: Completed W517 */
error_reporting(E_ALL); // Turn on all errors, warnings and notices for easier debugging
// API request variables
$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1'; // URL to call
$version = '1.0.0'; // API version supported by your application
$appid = 'XXX'; // Replace with your own AppID
$globalid = 'EBAY-US'; // Global ID of the eBay site you want to search (e.g., EBAY-DE)
$query = 'ford mustang'; // You may want to supply your own query
$safequery = urlencode($query); // Make the query URL-friendly
$i = '0'; // Initialize the item filter index to 0
// Create a PHP array of the item filters you want to use in your request
$filterarray =
array(
array(
'name' => 'MaxPrice',
'value' => '1000000',
'paramName' => 'Currency',
'paramValue' => 'USD'),
array(
'name' => 'MinPrice',
'value' => '100',
'paramName' => 'Currency',
'paramValue' => 'USD'),
array(
'name' => 'SoldItemsOnly',
'value' => 'true'),
);
function CurrencyFormat($number)
{
$decimalplaces = 2;
$decimalcharacter = '.';
$thousandseparater = ',';
return number_format($number,$decimalplaces,$decimalcharacter,$thousandseparater);
}
// 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";
}
}
else {
if($value != "") {
$urlfilter .= "&itemFilter($i).$key=$value";
}
}
}
$i++;
}
return "$urlfilter";
} // End of buildURLArray function
// Build the indexed item filter URL snippet
buildURLArray($filterarray);
// Construct the findItemsByKeywords HTTP GET call
$apicall = "$endpoint?";
$apicall .= "OPERATION-NAME=findCompletedItems";
$apicall .= "&SERVICE-VERSION=$version";
$apicall .= "&SECURITY-APPNAME=$appid";
$apicall .= "&GLOBAL-ID=$globalid";
$apicall .= "&keywords=$safequery";
$apicall .= "&categoryId=213";
$apicall .= "&paginationInput.entriesPerPage=20";
$apicall .= "$urlfilter";
// Load the call and capture the document returned by eBay API
$resp = simplexml_load_file($apicall);
// Check to see if the request was successful, else print an error
if ($resp->ack == "Success") {
$results = '';
// If the response was loaded, parse it and build links
foreach($resp->searchResult->item as $item) {
if ($item->pictureURLLarge) {
$pic = $item->pictureURLLarge;
} else {
$pic = $item->galleryURL;
}
$link = $item->viewItemURL;
$title = $item->title;
$price = $item->sellingStatus->convertedCurrentPrice;
$bids = $item->sellingStatus->bidCount;
$end = $item->listingInfo->endTime;
$fixed = date('M-d-Y', strtotime($end));
if(empty($bids)){
$bids = 0;
}
// For each SearchResultItem node, build a link and append it to $results
$results .= "<div class=\"item\"><div class=\"ui small image\"><a href=\"$link\" target=\"_blank\"><img height=\"200px\" width=\"130px\" src=\"$pic\"></a></div><div class=\"content\"><div class=\"header\"><a href=\"$link\" target=\"_blank\">$title</a></div><div class=\"meta\" style=\"margin-top:.1em\"><span class=\"price\"></span><div class=\"extra\">Sold Date: $fixed</div><div class=\"extra\"><button class=\"ui button\"><a href=\"$link\" target=\"_blank\"><b>Number of Bids:</b> $bids </a></button></div><div class=\"extra\"><a href=\"$link\" target=\"_blank\"><button class=\"ui orange button\">Sold Price: $$price</button></a></div><div class=\"description\"></div></div></div></div>";
}
}
// If the response does not indicate 'Success,' print an error
else {
$results = "<h3>Oops! The request was not successful. Make sure you are using a valid ";
$results .= "AppID for the Production environment.</h3>";
}
?>