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

时间:2012-05-13 20:23:00

标签: c# ebay

我正在使用此代码部分使用ebay FindingAPI查找所有拍卖类型的项目。现在我想过滤那些在指定日期内开始的项目(例如:2天)。如何添加此首选项??

检查此link和偏好设置类型。这是代码部分:

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());
}

1 个答案:

答案 0 :(得分:1)

这应该可以让你大致得到你需要的东西。设置用于比较的两个日期。

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());
                    }