2

ebays search APIを使用して単純な呼び出しを実行しようとしていますが、呼び出しを行っても応答がなく、問題は実際の呼び出し自体にあります。

$endpoint = 'http://open.api.ebay.com/shopping?';  
$responseEncoding = 'XML';   
$version = '631';   // API version number
$appID   = 'asdf3e6e3'; 
$itemType  = "AllItemTypes";
$itemSort  = "EndTime";

//find items advanced
$apicalla  = "$endpoint"
    ."callname=FindItemsAdvanced"
    ."&version=$version"
    ."&siteid=0"
    ."&appid=$appID"
    ."&MaxEntries=10"
    ."&ItemSort=EndTime"
    ."&ItemType=AllItemTypes"
    ."&IncludeSelector=SearchDetails"
    ."&responseencoding=$responseEncoding";

    $resp = simplexml_load_file($apicalla);

この呼び出しは、

http://open.api.ebay.com/shopping?callname=FindItemsAdvanced&version=631&siteid=0&appid=asdf3e6e3&MaxEntries=10&ItemSort=EndTime&ItemType=AllItemTypes&IncludeSelector=SearchDetails&responseencoding=XML

私の質問は、この単純な検索呼び出しを行うために何が欠けているのかということです。

4

2 に答える 2

4

eBayのShoppingAPIを使用しようとしているようです。具体的には、FindItemsAdvancedかなり前に廃止され、機能しなくなった可能性があると思われる呼び出しです(呼び出し参照には表示されなくなりました)。あなたがしたいのはfindItemsAdvanced、eBayのFindingAPIからの使用を使用することです。

まず、APIエンドポイントとクエリ文字列パラメータを少し変更する必要があります(詳細については前述の呼び出しリファレンスを参照してくださいが、これはもっと似ていると思います(少なくとも6か月間呼び出しにfindItemsAdvanced触れていません)findItemsAdvanced、だから私はこれをテストしていません):

$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1?';  
$responseEncoding = 'XML';   
$version = '1.8.0';   // API version number (they're actually up to 1.11.0 at this point
$appID   = 'asdf3e6e3'; 
$itemSort  = "EndTimeSoonest";

//find items advanced
$apicalla  = "$endpoint"
    ."OPERATION-NAME=findItemsAdvanced"
    ."&SERVICE-VERSION=$version"
    ."&GLOBAL-ID=EBAY-US"
    ."&SECURITY-APPNAME=$appID"
    //."&MaxEntries=10"    // look for an equivalent for this (maybe paginationInput.entriesPerPage?)
    ."&sortOrder=EndTimeSoonest"
    //."&ItemType=AllItemTypes"   // not needed AFAICT, otherwise look at itemFilterType
."&descriptionSearch=true";
    ."& RESPONSE-DATA-FORMAT=$responseEncoding";

$resp = simplexml_load_file($apicalla);

これに加えて、を使用するfindItemsAdvancedには、検索対象をカテゴリ(categoryId)またはキーワード(keywords)のいずれかで指定する必要があるため、「クエリを指定してください!」エラーメッセージ。

したがって、次のようなものも追加する必要があります(キーワードを想定)。

$keywords = "something";
$apicalla .= "&keywords=" . urlencode($keywords);

あなたに以下を与える:

$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1?';  
$responseEncoding = 'XML';   
$version = '1.8.0';   // API version number (they're actually up to 1.11.0 at this point
$appID   = 'asdf3e6e3'; 
$itemSort  = "EndTimeSoonest";
$keywords = "something";    // make sure this is a valid keyword or keywords

//find items advanced
$apicalla  = "$endpoint"
    ."OPERATION-NAME=findItemsAdvanced"
    ."&SERVICE-VERSION=$version"
    ."&GLOBAL-ID=EBAY-US"
    ."&SECURITY-APPNAME=$appID"
    //."&MaxEntries=10"    // look for an equivalent for this (maybe paginationInput.entriesPerPage?)
    ."&sortOrder=$itemSort"
    //."&ItemType=AllItemTypes"   // not needed AFAICT, otherwise look at itemFilterType
    ."&descriptionSearch=true";
    ."& RESPONSE-DATA-FORMAT=$responseEncoding"
    ."&keywords=" . urlencode($keywords);

$resp = simplexml_load_file($apicalla);

最後の注意:結果で見つかった特定のアイテムの詳細をロードする場合でも、Shopping API(具体的にはGetSingleItemおよびGetMultipleItems呼び出し)を使用する必要があります。したがって、最終的にはショッピングAPIと検索APIを組み合わせて使用​​できます。

于 2012-05-02T19:32:11.283 に答える
1

次のようになります。

<?php
$url = 'http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.11.0&SECURITY-APPNAME=YOUR_APP_ID&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&paginationInput.entriesPerPage=2&keywords=ipod&siteid=203&GLOBAL-ID=EBAY-IN';
$xml = file_get_contents( $url );
$xml = simplexml_load_string( $url );
?>

eBay開発者アカウントにログインし、次のリンクをクリックします。APIテストツールを使用して通話をテストします

お役に立てれば。

于 2012-05-03T05:08:21.270 に答える