Подтвердить что ты не робот

EBay API - Как получить большие изображения предметов?

Как получить изображение большого элемента с помощью eBay API? Вызов API ниже возвращает эскиз, когда я использую galleryURL. Я попытался заменить его PictureURLLarge, но это не вернуло URL.

(Линия, о которой я говорю, - это 16-й снизу: $pic = $item- > galleryURL;)

// API request variables
       $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';  // URL to call
       $version = '1.11.0';  // API version supported by your application
       $appid = 'XXXXX';  // Replace with your own AppID
       $globalid = 'EBAY-US';  // Global ID of the eBay site you want to search (e.g., EBAY-DE)
       $query = "soft thin (shirt, tshirt, t-shirt)";  // 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' => '1500',
           'paramName' => 'Currency',
           'paramValue' => 'USD'),
           array(
           'name' => 'FreeShippingOnly',
           'value' => 'false',
           'paramName' => '',
           'paramValue' => ''),
           array(
           'name' => 'ListingType',
           'value' => array('AuctionWithBIN','FixedPrice','StoreInventory'),
           'paramName' => '',
           'paramValue' => ''),
         );

       // 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 findItemsAdvanced HTTP GET call 
       $apicall = "$endpoint?";
       $apicall .= "OPERATION-NAME=findItemsAdvanced";
       $apicall .= "&SERVICE-VERSION=$version";
       $apicall .= "&SECURITY-APPNAME=$appid";
       $apicall .= "&GLOBAL-ID=$globalid";
       $apicall .= "&descriptionSearch=true";
       $apicall .= "&categoryId=110";
       $apicall .= "&keywords=$safequery";
       $apicall .= "&paginationInput.entriesPerPage=100";
       $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) {
           $pic    = $item->galleryURL;
           $link   = $item->viewItemURL;
           $title  = $item->title;
           $ship = (float) $item->shippingInfo->shippingServiceCost;
           $price = (float) $item->sellingStatus->currentPrice;
           $sell = ($ship + $price);

           // For each SearchResultItem node, build a link and append it to $results
           $results .= "<a href=\"$link\" title=\"$title\" target=\"_blank\"><div class=\"shirt-block\"><img src=\"$pic\" width=\"200\" height=\"200\"><br /><br /><span class=\"cost\">$$sell</span></div></a>";
         }
       }
       // 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>";
       }
4b9b3361

Ответ 1

Пробовал ли вы последний метод, представленный на форуме eBay ?

Я могу помочь объяснить и направить вас.

Этот член предлагает включить $apicall .= "&outputSelector=$outputSelector"; в вашу конструкцию запроса findItemsAdvanced.

В этот момент я проверил бы возвращенный XML файл, чтобы увидеть, включен ли он через Firebug (щелкните вкладку NET, затем XHR ниже). В Chrome просто включите Инструменты разработчика и перейдите на вкладку NETWORK, чтобы увидеть возвращенный XML файл. Нажмите файл, чтобы открыть его, и вы увидите содержимое без пробелов.

Поскольку XML файл не будет красивым, скопируйте этот контент и вставьте его ЗДЕСЬ, чтобы украсить его для удобства чтения.

Пример XML файла ЗДЕСЬ, который показывает как pictureURLLarge, так и pictureURLSuperSize.

После того, как вы подтвердите, что URL-адрес для большого изображения включен в ваш XML файл, второй шаг заключается в том, чтобы затем использовать его в вашей разметке следующим образом:

$pic = $item->pictureURLLarge;

или

$pic = $item->pictureURLSuperSize;

Извините, у меня нет своего собственного eBay AppID, и их ссылка API Playground сломана, но может помочь дальше, все что-то неясно.

Чтобы убедиться, что первый шаг должен получить запрос Large Image, а второй шаг - просто использовать изображение.