繁体   English   中英

易趣API - getCategories超时

[英]eBay API - getCategories timeout

试图从Ebay获取所有类别以推入数据库。 我已经尝试增加底层api上下文的超时值,但是大约两分钟后我仍然会超时 - 我还需要做什么?

        var c = new eBay.Service.Call.GetCategoriesCall(this.apiContext);
        c.CategorySiteID = ((int)siteId).ToString(); // siteId is an eBay SiteCode enum value
        var version = c.GetCategoriesVersion();
        c.DetailLevelList = new DetailLevelCodeTypeCollection();
        c.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
        c.ViewAllNodes = !onlyLeafCategories;
        c.Timeout = 1000*60*20;
        c.GetCategories(); // this causes a connection closed / timeout

试试这个代码,它对我有用:

// get all categories from eBay
                    ApiContext context = GetApiContext();

                    GetCategoriesCall apiCall = new GetCategoriesCall(context)
                    {
                        EnableCompression = true,
                        ViewAllNodes = true

                    };
                    apiCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
                    apiCall.GetCategories();

    public static ApiContext GetApiContext()
    {
        //apiContext is a singleton,
        //to avoid duplicate configuration reading
        if (apiContext != null)
        {
            return apiContext;
        }
        else
        {
            apiContext = new ApiContext();

            //set Api Server Url
            apiContext.SoapApiServerUrl = "https://api.ebay.com/wsapi";

            //set Api Token to access eBay Api Server
            ApiCredential apiCredential = new ApiCredential();
            apiCredential.eBayToken ="YOUR_TOKEN";
            apiContext.ApiCredential = apiCredential;
            //set eBay Site target to US
            apiContext.Site = eBay.Service.Core.Soap.SiteCodeType.US;
            return apiContext;
        }
    }

暂无
暂无

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

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