1

我正在使用以下代码根据关键字搜索项目:

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using ConsoleApplication1.EbayServiceReference;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            TextWriter tw = new StreamWriter("1001.txt");
            using (FindingServicePortTypeClient client = new FindingServicePortTypeClient())
            {
                MessageHeader header = MessageHeader.CreateHeader("My-CustomHeader", "http://www.mycustomheader.com", "Custom Header");
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);
                    HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                    httpRequestProperty.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "myappid");
                    httpRequestProperty.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords");
                    httpRequestProperty.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

                    FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();

                    request.keywords = "gruen wristwatch parts -(sara,quartz,embassy,bob,robert,elephants,adidas)";
                    FindItemsByKeywordsResponse check = client.findItemsByKeywords(request);
                    int totalEntries = check.paginationOutput.totalEntries;
                    Console.WriteLine(totalEntries);
                    int totalPages = (int)Math.Ceiling((double)totalEntries / 100.00);

                    for (int curPage = 1; curPage <= totalPages; curPage++)
                    {
                        PaginationInput pagination = new PaginationInput();

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

                        FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);

                        foreach (var item in response.searchResult.item)
                        {
                            Console.WriteLine(item.viewItemURL.ToString());
                            tw.WriteLine(item.viewItemURL.ToString());
                        }
                    }
                }
            }

            tw.Close();
            Console.WriteLine("end");
            Console.ReadKey();
        }
    }
}

这是原始关键字集:

gruen 手表零件 -sara -quartz -embassy -bob -robert -elephants -adidas

如果我使用这个关键字集,它会返回 3 个项目:结果在这里

我已将其格式化为FindingAPI根据此参考使用

gruen 手表零件-(萨拉、石英、大使馆、鲍勃、罗伯特、大象、阿迪达斯)

它返回 13 个项目。我认为它也应该返回 3 个项目。造成这种差异的原因是什么,我可以使用替代语法获得预期结果吗?

4

0 回答 0