2017-12-08 1 views
0

이베이 (ebay)에있는 내 스토어에서 모든 제품을 가져오고 싶습니다.이 코드는 제가 필요한 모든 데이터를 가져 오는 코드입니다. 내가 이베이의 개발자 프로그램에 등록한 후 제작 용 키를 만들었습니다. 내가이 API 예외 무엇입니까이 코드를 실행 한 후API 요청에서 인증 토큰의 유효성 검사가 실패했습니다. eBay 사용 .Net SDK

#region Feilds 
ApiContext ApiContext = new ApiContext(); 
CallRetry OCallRetry = new CallRetry(); 
ApiCall ApiCall = new ApiCall(); 
GetItemCall GetCall = new GetItemCall(); 

#endregion 

#region Utilities 
public void GetCredentials() 
{ 
    ApiContext.ApiCredential.ApiAccount.Developer = "xxxxxxxx";   //use your dev ID 
    ApiContext.ApiCredential.ApiAccount.Application = "xxxxxx";  //use your app ID 
    ApiContext.ApiCredential.ApiAccount.Certificate = "xxxxxxxxxxxx";   //use your cert ID 
    ApiContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["Token"];     //set the AuthToken 
} 

public void InitializeAPI() 
{ 
    ApiContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; 
    ApiContext.Site = eBay.Service.Core.Soap.SiteCodeType.India; 
    ApiContext.Version = "459"; 
} 

public void SetupAPILog() 
{ 
    //very important, let's setup the logging 
    ApiLogManager ApiLog = new ApiLogManager(); 
    ApiLog.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); 
    ApiLog.EnableLogging = true; 
    ApiContext.ApiLogManager = ApiLog; 
} 

public void ConsumeAPI() 
{ 

    OCallRetry.DelayTime = 1; 
    OCallRetry.MaximumRetries = 3; 
    StringCollection oErrorCodes = new StringCollection(); 
    oErrorCodes.Add("10007"); 
    oErrorCodes.Add("2"); 
    oErrorCodes.Add("251"); 
    OCallRetry.TriggerErrorCodes = oErrorCodes; 
    TypeCollection oExceptions = new TypeCollection(); 
    oExceptions.Add(typeof(System.Net.ProtocolViolationException)); 

    oExceptions.Add(typeof(SdkException)); 
    OCallRetry.TriggerExceptions = oExceptions; 
    ApiContext.CallRetry = OCallRetry; 
    ApiContext.Timeout = 120000; 
    GetSellerListCall ApiSellerList = new GetSellerListCall(ApiContext); 

    ApiSellerList.Version = ApiContext.Version; 
    ApiSellerList.Site = ApiContext.Site; 
    ApiSellerList.GranularityLevel = eBay.Service.Core.Soap.GranularityLevelCodeType.Fine; 

    // enable the compression feature 
    ApiSellerList.EnableCompression = true; 
    ApiSellerList.DetailLevelList.Add(eBay.Service.Core.Soap.DetailLevelCodeType.ReturnAll); 

    PaginationType oPagination = new PaginationType(); 
    oPagination.EntriesPerPage = 200; 
    oPagination.EntriesPerPageSpecified = true; 
    oPagination.PageNumber = 1; 
    oPagination.PageNumberSpecified = true; 
    ApiSellerList.Pagination = oPagination; 
    ApiSellerList.EndTimeFilter = new TimeFilter(DateTime.Now, DateTime.Now.AddMonths(3)); 
    ApiSellerList.Sort = 2; 
    try 
    { 
     ItemTypeCollection oItems = ApiSellerList.GetSellerList(); 
     foreach (ItemType oItem in oItems) 
     { 
      Console.WriteLine("ItemID is " + oItem.ItemID); 
      Console.WriteLine("This item is of type " + oItem.ListingType.ToString()); 
      if (0 < oItem.SellingStatus.BidCount) 
      { 
       // The HighBidder element is valid only if there is at least 1 bid 
       Console.WriteLine("High Bidder is " + oItem.SellingStatus.HighBidder.UserID); 
      } 
      Console.WriteLine("Current Price is " + oItem.SellingStatus.CurrentPrice.currencyID.ToString() + " " + oItem.SellingStatus.CurrentPrice.Value.ToString()); 
      Console.WriteLine("End Time is " + oItem.ListingDetails.EndTime.ToLongDateString() + " " + oItem.ListingDetails.EndTime.ToLongTimeString()); 
      Console.WriteLine(""); 
      // the data that is accessible through the item object 
      // for different GranularityLevel and DetailLevel choices 
      // can be found at the following URL: 
      // http://developer.ebay.com/DevZone/SOAP/docs/WebHelp/GetSellerListCall-GetSellerList_Best_Practices.html 
     } 

    } 

    catch (ApiException oApiEx) 
    { 
     // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do 
     Console.WriteLine(oApiEx.Message); 
     return; 
    } 
    catch (SdkException oSdkEx) 
    { 
     // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do 
     Console.WriteLine(oSdkEx.Message); 
     return; 
    } 
    catch (Exception oEx) 
    { 
     // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do 
     Console.WriteLine(oEx.Message); 
     return; 
    } 
} 

#endregion  

를 따를 때 내 코드는 "API 요청에서 인증 토큰이 실패의 검증 을."

스택 트레이스 - eBay.Service.Call.GetSellerListCall.GetSellerList에서 eBay.Service.Core.Sdk.ApiCall.Execute()에서 eBay.Service.Core.Sdk.ApiCall.SendRequest()()에서의

Nop.Services.EbayExport.ExportProducts.ConsumeAPI는() 나는 생산 섹션의 키를 생성 "ApiContext.ApiCredential.eBayToken"에 대한

누구나 사용하여 토큰을 얻기 위해 "OAuth를 응용 프로그램 토큰을 가져 오기"를 클릭 .NetSDK 이베이 API를 위해?

맨 처음 것은, 내가 코드에서 발견 한
+0

그럼 도움이 될 수 있습니다 –

답변

0

는 API를 사용한 한 버전 - 459은

이 지금은 완전히 무효이며, 이베이 버전 지원 가장 낮은 941

업데이트하십시오이다 버전 및 시도하십시오. 아래의 작업 코드 버전 내가 "Auth'n'auth"에서 토큰을받은 후 그것을 해결, 당신에게

https://ebaydts.com/eBayKBDetails?KBid=1686

관련 문제