簡體   English   中英

eBay API GetSessionID方法不返回會話ID

[英]eBay API GetSessionID method not returning session ID

我正在使用eBay API調用GetSessionId方法,但是該方法在我的ASP.NET MVC4應用程序中返回了空的SessionID

誰能幫我解決問題嗎?

我正在使用以下代碼段。

 string signinURL = "https://api.sandbox.ebay.com/wsapi";
string callname = "GetSessionID";
string appID = ConfigurationManager.AppSettings["ebay_AppId"];
string version = "768";
string eBayToken = ConfigurationManager.AppSettings["testToken"];
string endpoint = signinURL + "?callname=" + callname +
                    "&appid=" + appID +
                    "&version=" + version +
                    "&routing=default";



eBayAPIInterfaceClient service = new eBayAPIInterfaceClient("eBayAPI", endpoint);
GetSessionIDRequest req = new GetSessionIDRequest();
req.RequesterCredentials = new CustomSecurityHeaderType();

req.RequesterCredentials.Credentials = new UserIdPasswordType();
req.RequesterCredentials.Credentials.AppId = AppConstants.AppId;
req.RequesterCredentials.Credentials.DevId = AppConstants.DevId;
req.RequesterCredentials.Credentials.AuthCert = AppConstants.CertId;
req.RequesterCredentials.eBayAuthToken = AppConstants.ebayToken;
GetSessionIDRequestType reqType = new GetSessionIDRequestType();
reqType.RuName = AppConstants.RuName;
reqType.Version = version;
GetSessionIDResponseType res = service.GetSessionID(ref req.RequesterCredentials, reqType);
if (res.Ack == AckCodeType.Success)
{
    string ebaySignInUrl = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=" + 
                           AppConstants.RuName + "&SessionID=" + res.SessionID;
    Response.Redirect(ebaySignInUrl);
}

最后,我找出了問題所在,問題出在eBay API上。 它不會填充SessionID字段。 可能是API中的錯誤。 修改后的值可以在響應對象的XmlElement Array字段中找到。 所以我在這里獲得SessionID。

if (response.Any.Length >= 1)
      {
        var SessionId=response.Any.First().InnerText;
      }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM