简体   繁体   English

ebay FindingAPI如何查找给定日期范围内指定的项目

[英]ebay FindingAPI how to find items specified within a given day range

I am using this code portion to find all items which are in Auction type using ebay FindingAPI . 我使用此代码部分使用易趣FindingAPI查找所有拍卖类型的项目。 Now I want to filter those items which have been started within a specified day (eg: 2 days) . 现在我想过滤那些在指定日期内开始的项目(例如:2天)。 How can I add this preference?? 我怎样才能添加这个偏好?

Check this link and preference type . 检查此链接和首选项类型。 Here is the code portion : 这是代码部分:

IPaginationInput pagination = new PaginationInput();

pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 100;
pagination.pageNumberSpecified = true;
pagination.pageNumber = curPage;
request.paginationInput = pagination;

ItemFilter if1 = new ItemFilter();
ItemFilter if2 = new ItemFilter();
if1.name = ItemFilterType.ListingType;
if1.value = new string[] { "Auction" };




ItemFilter[] ifa = new ItemFilter[1];
ifa[0] = if1;
request.itemFilter = ifa;

FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


foreach (var item in response.searchResult.item)
{

    tw.WriteLine(item.viewItemURL.ToString());
    links.Add(item.viewItemURL.ToString());
}

This should get you roughly what you need. 这应该可以让你大致得到你需要的东西。 Set the two dates used to compare to whatever you want. 设置用于比较您想要的两个日期。

IPaginationInput pagination = new PaginationInput();

                    pagination.entriesPerPageSpecified = true;
                    pagination.entriesPerPage = 100;
                    pagination.pageNumberSpecified = true;
                    pagination.pageNumber = curPage;
                    request.paginationInput = pagination;

                    ItemFilter if1 = new ItemFilter();
                    ItemFilter if2 = new ItemFilter();
                    if1.name = ItemFilterType.ListingType;
                    if1.value = new string[] { "Auction" };




                    ItemFilter[] ifa = new ItemFilter[1];
                    ifa[0] = if1;
                    request.itemFilter = ifa;

                    FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


                    foreach (var item in response.searchResult.item)
                    {
                         // EDIT
                         if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow) > -1) // -1 is earlyer; 0 is same; +1 is later then
                         {
                           if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow.AddDays(-2)) == -1 )
                           {
                               // You have an Item that was started between now and two days ago.
                               // Do something

                           }
                        }
                        // END EDIT

                        tw.WriteLine(item.viewItemURL.ToString());
                        links.Add(item.viewItemURL.ToString());
                    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM