私はEbayのFindingAPIを使用して以下のコードを使用して、キーワードに一致するEbayのすべてのアイテムリンクを取得しています。この場合、「gruenwatch」がキーワードです。このコードには、100を超えるアイテムのリンクは表示されません。すべてのアイテムのリンクを表示するように変更するにはどうすればよいですか?
**元のappidを置き換えました
Program.cs
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TextWriter tw = new StreamWriter("link.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", "MY-APP-ID");
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 watch";
PaginationInput pagination = new PaginationInput();
pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 250;
pagination.pageNumberSpecified = true;
pagination.pageNumber = 10;
request.paginationInput = pagination;
FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);
foreach (var item in response.searchResult.item)
{
//Console.WriteLine(item.title);
tw.WriteLine(item.viewItemURL.ToString());
Console.WriteLine(item.viewItemURL.ToString());
}
}
}
tw.Close();
Console.ReadKey();
}
}
app.configはここにあります
これが私が作った解決策です:
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 watch";
FindItemsByKeywordsResponse check = client.findItemsByKeywords(request);
int totalEntries = check.paginationOutput.totalEntries;
int cnt = 0;
int totalPages = (int)Math.Ceiling((double)totalEntries/100.00);
bool flag = true;
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();
}
}
}