2012-05-20 9 views
10

eBay APIを使用して大きなアイテムの画像を取得するにはどうすればよいですか? galleryURLを使用すると、以下のAPI呼び出しでサムネイル画像が返されます。 PictureURLLargeに置き換えようとしましたが、URLを返しませんでした。eBay API - 大きなアイテムの写真を取得するには?

(私はを参照していますラインが下から16日である:$ PIC = $アイテム - > 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>"; 
     } 
+0

ループ内で 'var_dump($ item)'できますか?また、 '$ item-> pictureURLLarge'(大文字と小文字を区別)を試しましたか? –

+1

私はこの問題を発見しました。それは本当に愚かです。説明の検索を「true」に設定すると、pictureURLLargeを取得するoutputSelectorを使用できなくなります。なぜ私が泣きたいのか分からない。 – Carson

答えて

7

あなたがeBay Forum?

で提供される最も最近の方法を試してみました

私はあなたを説明しガイドするのを助けることができます。

そのメンバーは、リクエストの構成に$apicall .= "&outputSelector=$outputSelector";を含めるよう提案しています。

その時点で、のXMLファイルがFirebug経由で含まれているかどうかを確認します(NETタブをクリックし、次にXHRをクリックします)。 Chromeでは、開発ツールを有効にして[ネットワーク]タブをクリックすると、返されたXMLファイルが表示されます。展開するファイルをクリックすると、空白のないコンテンツが表示されます。

XMLファイルがきれいにならないため、そのコンテンツをコピーしてHEREに貼り付けて読みやすくしてください。 pictureURLLargeと示さpictureURLSuperSizeの両方を持っている

サンプルXMLファイルHERE

あなたは第二のステップは、そのようにように、あなたのマークアップでそれを使用することで、大きな画像のURLは、あなたのXMLファイルに含まれていることを確認したら:

$pic = $item->pictureURLLarge; 

または

$pic = $item->pictureURLSuperSize; 

申し訳ありません私は自分自身を持っていませんeBay AppIDをテストし、彼らのAPIプレイグラウンドリンクが壊れていますが、さらに何かが不明であることを助けることができます。

確かに、第一歩は大画像要求を得ることであると第二ステップは、単に画像を使用することです。

+0

ありがとうございます。早急に返信しないと申し訳ありませんが、私はインターネットに接続していないメキシコにいました。上記のことを試してみましたが、ファイアバグを使用するとXMLファイルが表示されません。ウェブサイトは:http://shirtcake.com/もっと見ることができるかもしれない? – Carson

+0

閉じているbodyタグの最初のインスタンスを削除する必要があります。最初の閉じたbodyタグの下にjQuery v1.71の別のインスタンスがありましたが、以前は北に見える場合はv1.6.4がインストールされていました。私はeBayのリクエストを見ていないし、あなたが投稿した上記のマークアップも見ていない。それはどこにある? – arttronics

+0

Hum、多分あなたのPHPプロセスにエラーがあります。この[eBayチュートリアル](http://developer.ebay。com/devzone/finding/HowTo/PHP_SearchInterm_NV_XML/PHP_SearchInterm_NV_XML.html)にはダウンロード可能なプロジェクトファイルとPHPプロセスが正しいことを確認するためのステップバイステップの説明があります。また、あなたのものに類似したマークアップを表示するPHPファイルの例もあり、PHPプロセスの作成/設定を助けてくれます。これは役に立ちますか? – arttronics

関連する問題