function ebay_pn_plugin_short_dis($postid,$query) { if($query!=""){ //$query = str_replace(' ', '+', $query); //---------get saved options $admin_campid=get_option('ebay_pn_plugin_campid'); $dis_icon=get_option('ebay_pn_plugin_dis_icon'); $dis_search_bar=get_option('ebay_pn_plugin_dis_search_bar'); $cl_top_bar="#".get_option('ebay_pn_plugin_cl_top_bar'); $cl_top_txt="#".get_option('ebay_pn_plugin_cl_top_txt'); $row_color="#".get_option('ebay_pn_plugin_row_color'); $alt_row_color="#".get_option('ebay_pn_plugin_alt_row_color'); $cl_title_txt="#".get_option('ebay_pn_plugin_cl_title_txt'); $cl_details_txt="#".get_option('ebay_pn_plugin_cl_details_txt'); $cl_bot_bar="#".get_option('ebay_pn_plugin_cl_bot_bar'); $cl_bot_txt="#".get_option('ebay_pn_plugin_cl_bot_txt'); $row_highlight="#".get_option('ebay_pn_plugin_row_highlight'); $num_rows=get_option('ebay_pn_plugin_num_rows'); $contribute=get_option('ebay_pn_plugin_contribute'); $linkback=get_option('ebay_pn_plugin_linkback'); //set campaign id $campid = $admin_campid; //get sort and filter options $globalid=get_option('ebay_pn_plugin_globalid'); // Global ID of the eBay site you want to search (e.g., EBAY-US) $search_desc=get_option('ebay_pn_plugin_search_desc'); $category=get_option('ebay_pn_plugin_category'); $auct_type=get_option('ebay_pn_plugin_auct_type'); $min_price=get_option('ebay_pn_plugin_min_price'); $min_price = preg_replace ('/[^\d\s]/', '', $min_price); $max_price=get_option('ebay_pn_plugin_max_price'); $max_price = preg_replace ('/[^\d\s]/', '', $max_price); $min_bids=get_option('ebay_pn_plugin_min_bids'); $max_bids=get_option('ebay_pn_plugin_max_bids'); $condition=get_option('ebay_pn_plugin_condition'); $sort_by=get_option('ebay_pn_plugin_sort_by'); $zip=get_option('ebay_pn_plugin_zip'); // 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 = 'MiSchell-781a-4f01-8899-3d2ab7c56610'; // Replace with your own AppID $filterArray = array( array( 'name' => 'MaxPrice', 'value' => $max_price, 'paramName' => 'Currency', 'paramValue' => 'EUR'), array( 'name' => 'MinPrice', 'value' => $min_price, 'paramName' => 'Currency', 'paramValue' => 'EUR'), array( 'name' => 'MaxBids', 'value' => $max_bids, 'paramName' => '', 'paramValue' => ''), array( 'name' => 'MinBids', 'value' => $min_bids, 'paramName' => '', 'paramValue' => ''), array( 'name' => 'Condition', 'value' => $condition, 'paramName' => '', 'paramValue' => ''), array( 'name' => 'ListingType', 'value' => $auct_type, 'paramName' => '', 'paramValue' => ''), ); for ($counter = 0; $counter <= 4; $counter += 1) { if($filterArray[$counter]['value']==""){ unset($filterArray[$counter]); } } // Build item filters URL array function buildURLArray2 ($filterArray) { global $filter1; //global $i; $i = '0'; // Initialize the item filter index array to 0 // Iterate through each filter in the array foreach($filterArray as $itemFilter) { // Iterate through each key in the filter foreach ($itemFilter as $key =>$value) { $r = '0'; //A number that increments each time the above "for" loops; if(is_array($value)) { //if the 'value' var content is an array if($value != "") { //check to make sure the content isn't empty foreach($value as $j => $content) { $filter1 .= "&itemFilter($i).$key($j)=$content"; } } } else { //this isnt an array so just print the single contents of the 'value' container, no indexing of keys needed if($value != "") { $filter1 .= "&itemFilter($i).$key=$value"; } } $r++; } $i++; } return $filter1; } // End of buildURLArray function $urlfilter=buildURLArray2($filterArray); // Load the call and capture the document returned by eBay API $search = $query; $SafeQuery = urlencode($query); // Make the query URL-friendly // Construct the findItemsAdvanced call $apicall = "$endpoint?"; $apicall .= "OPERATION-NAME=findItemsAdvanced"; $apicall .= "&SERVICE-VERSION=$version"; $apicall .= "&SECURITY-APPNAME=$appid"; $apicall .= "&GLOBAL-ID=$globalid"; $apicall .= "&keywords=$SafeQuery"; if($category!=""){ $apicall .= "&categoryId=$category"; } if($zip!=""){ $apicall .= "&buyerPostalCode=$zip"; } $apicall .= "&affiliate.networkId=9"; $apicall .= "&affiliate.trackingId=$campid"; if($sort_by!=""){ $apicall .= "&sortOrder=$sort_by"; } $apicall .= "&descriptionSearch=$search_desc"; $apicall .= "&paginationInput.entriesPerPage=$num_rows"; $apicall .= $urlfilter; $resp = simplexml_load_file($apicall); // Check to see if the response was loaded, else print an error if ($resp->searchResult->item) { $results = ''; $result = "
"; } else { // If there was no response, print an error echo "Oops! Zu deinem Suchbegriff gibt es leider keine Ergebnisse. Versuche einen anderen Suchbegriff!"; } $result .="
"; } return $result; } //------------------------------------------------------------------------- function getPrettyTimeFromEbayTime2($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 Tag" . plurals1($days).","; } if ($hours) { $retnStr .= " $hours Std,"; } if ($min) { $retnStr .= " $min Min"; } //if ($sec) { $retnStr .= " $sec sec" . plurals1($sec); } return $retnStr; } // function function plurals1($intIn) { // if $intIn > 1 return an 's', else return null string if ($intIn > 1) { return 'e'; } else { return ''; } } ?>
WordPress › Fehler