示例#1
0
        private void BtnGenerateSID_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (!validateApiAccount(Context))
                {
                    MessageBox.Show("Pleasse fill in Api Account first.");
                    return;
                }

                GetSessionIDCall gsc = new GetSessionIDCall(Context);
                if(txtRulName.Text==string.Empty)
                {
                    MessageBox.Show("Please input a RuName");
                    return;
                }
                //the rule name can be retrived from the app.config file, otherwise the user must input it himself.

                Context.RuName = txtRulName.Text;
                String sessionID = gsc.GetSessionID(Context.RuName);
                TxtSessionID.Text = sessionID;
            }
            catch(ApiException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        public static String getAuthenticateUrl(out String sessionId)
        {
            sessionId = "";

            ApiAccount apiAccount = new ApiAccount();
            apiAccount.Application = EbayAppId;
            apiAccount.Certificate = EbayCertId;
            apiAccount.Developer = EbayDevId;

            ApiContext localContext = new ApiContext();
            localContext.ApiCredential = new eBay.Service.Core.Sdk.ApiCredential();
            localContext.ApiCredential.ApiAccount = apiAccount;
            localContext.RuName = EbayRuName;
            localContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.API_SERVER_URL);
            localContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.SIGNIN_URL);

            GetSessionIDCall apiCall = new GetSessionIDCall(localContext);
            apiCall.RuName = EbayRuName;
            apiCall.Execute();

            sessionId = apiCall.SessionID;
            String authUrl = String.Format("{0}&RuName={1}&SessID={2}", localContext.SignInUrl, EbayRuName, sessionId);
            return authUrl;
        }
 public static string GetSessionID()
 {
     ApiContext context = AppSettingHelper.GetGenericApiContext("US");
     GetSessionIDCall calla = new GetSessionIDCall(context);
     return calla.GetSessionID(context.RuName);
 }