Как запросить товары с помощью ebay api?

Как я могу позвонить на eBay и попросить его вернуть массив результатов поиска?

Вот что я придумал до сих пор:

string endpoint = "https://api.ebay.com/wsapi";
string siteId = "0";
string appId = "*";     // use your app ID
string devId = "*";     // use your dev ID
string certId = "*";   // use your cert ID
string version = "405";

string requestURL = endpoint
+ "?callname=FindProducts"
+ "&siteid=" + siteId
+ "&appid=" + appId
+ "&version=" + version
+ "&routing=default"
+ "&AvailableItemsOnly=true"
+ "&QueryKeywords=nvidia"
+ "&itemFilter(0).name=ListingType"
+ "&itemFilter(0).value(0)=FixedPrice"
+ "&itemFilter(0).value(1)=Auction"
+ "&CategoryID=27386";

Как я могу обернуть его в запрос и получить ответ в какой-то структуре данных? Я получил SDK.


person Andrew    schedule 01.06.2012    source источник
comment
У них есть оболочка SDK .NET, поэтому вам не нужно обрабатывать все это вручную: developer.ebay.com/DevZone/WindowsSDK/docs/Getting%20Started/. Вы пробовали это?   -  person mellamokb    schedule 02.06.2012
comment
Не могли бы вы привести пример, который мог бы помочь мне с моей проблемой?   -  person Andrew    schedule 02.06.2012
comment
См. пример здесь: developer.ebay.com /DevZone/WindowsSDK/docs/Getting%20Started/. Оттуда, я полагаю, будет метод с именем FindProducts, который вы можете вызывать с параметрами, которые вы вручную вводите в строку. Вам не нужно возиться с созданием строк запросов, URL-адресов запросов, SOAP, ответов и т. д.   -  person mellamokb    schedule 02.06.2012
comment
Я попытался создать запрос FindItemsByKeywordsRequest = new FindItemsByKeywordsRequest (); но получаю сообщение "Ошибка 1. Не удалось найти тип или имя пространства имен "FindItemsByKeywordsRequest" (вам не хватает директивы using или ссылки на сборку?)", но ссылки есть...:\   -  person Andrew    schedule 02.06.2012


Ответы (1)


Мне нужно было использовать API поиска eBay;

    public GetItemCall getItemDataFromEbay(String itemId)
    {
        ApiContext oContext = new ApiContext();
        oContext.ApiCredential.ApiAccount.Developer = ""; // use your dev ID
        oContext.ApiCredential.ApiAccount.Application = ""; // use your app ID
        oContext.ApiCredential.ApiAccount.Certificate = ""; // use your cert ID
        oContext.ApiCredential.eBayToken = "";            //set the AuthToken

        //set the endpoint (sandbox) use https://api.ebay.com/wsapi for production
        oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi";

        //set the Site of the Context
        oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US;

        //the WSDL Version used for this SDK build
        oContext.Version = "735";

        //very important, let's setup the logging
        ApiLogManager oLogManager = new ApiLogManager();
        oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetItem.log", true, true, true));
        oLogManager.EnableLogging = true;
        oContext.ApiLogManager = oLogManager;

        GetItemCall oGetItemCall = new GetItemCall(oContext);

        //' set the Version used in the call
        oGetItemCall.Version = oContext.Version;

        //' set the Site of the call
        oGetItemCall.Site = oContext.Site;

        //' enable the compression feature
        oGetItemCall.EnableCompression = true;
        oGetItemCall.DetailLevelList.Add(eBay.Service.Core.Soap.DetailLevelCodeType.ReturnAll);
        oGetItemCall.ItemID = itemId;
        try
        {
            oGetItemCall.GetItem(oGetItemCall.ItemID);
        }
        catch (Exception E)
        {
            Console.Write(E.ToString());
            oGetItemCall.GetItem(itemId);
        }
        GC.Collect();
        return oGetItemCall;
    }
person Andrew    schedule 25.06.2012