eBay大中华区API开发者平台 开发者专区

搜 索
首页>API开发者平台>技术文档>.NET SDK例程:设置DetailLevel以及GranularityLevel呢

技术文档

问题
.NET SDK例程:设置DetailLevel以及GranularityLevel呢
解答
0
人觉得答案有帮助)

 

总述

设置某个调用的DetailLevel,你需要向此调用的DetailLevelList库中添加所需的DetailLevelCodeType。 同样的对于GranularityLevel,你需要在此调用的GranularityLevel属性中设置所需的GranularityLevelCodeType
 

 


 

 

详述

下面的C#例程展示了如何设置DetailLevel和GranularityLevel:
 

using System;
using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace SDKExamples
{

public class Samples

     public ApiContext context;
 
public string GetItem(string ItemID)
{
  GetItemCall apicall = new GetItemCall(GetContext());
  //Set the DetailLevel to get the Attribute Information
  apicall.DetailLevelList.Add(DetailLevelCodeType.ItemReturnAttributes);
  apicall.ItemID = "110021195125";
  apicall.Execute();
  //Get the information from the response
  string  title = apicall.Item.Title;
}

public void GetSellerList()
{
    GetSellerListCall apicall = new GetSellerListCall(GetContext());
  TimeFilter tf = new TimeFilter();
  tf.TimeFrom =  DateTime.Now.AddMinutes(1);
  tf.TimeTo = DateTime.Now.AddDays(30);           
  apicall.EndTimeFilter = tf;
  //Set the GranularityLevel to Coarse
  apicall.GranularityLevel = GranularityLevelCodeType.Coarse;
  apicall.Pagination = new PaginationType();
  apicall.Pagination.EntriesPerPage = 200;
  apicall.Pagination.PageNumber = 1;
  apicall.Execute();

  //Process each item
  foreach( ItemType item in apicall.ItemList)
  {
      //do the processing
  }
  //Get more pages if required, by incrementing apicall.Pagination.PageNumber
}
 

    public ApiContext GetContext()
    {

    if (context == null)
        {
           context = new ApiContext();

      // Set the Sandbox Credentials for the call
      context.ApiCredential.ApiAccount.Developer = "devID";
      context.ApiCredential.ApiAccount.Application = "appID";
      context.ApiCredential.ApiAccount.Certificate = "certID";
      context.ApiCredential.eBayToken = "token";

      // Set the Sandbox URL
      context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi"; 

      // Set logging
      context.ApiLogManager = newApiLogManager();
      context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("Messages.log",true, true, true));
      context.ApiLogManager.EnableLogging = true;

      // Set the version
      context.Version = "511";

        }
   return context;
    }

}

}

 


版本信息

上示例程基于此特定的版本:

API 架构版本 511
.NET SDK版本 eBay .NET SDK v511 Full Release

答案对您有帮助吗?

是,对我很有帮助
否,没解决我的问题