这是后台代码,前台没有任何操作。。。。。。
public partial class cb : System.Web.UI.Page { JavaScriptSerializer js = new JavaScriptSerializer(); protected void Page_Load(object sender, EventArgs e) { string code = Request.QueryString["code"].ToString(); if (!string.IsNullOrEmpty(code)) { string appkey = ConfigurationManager.AppSettings["appkey"]; string secret = ConfigurationManager.AppSettings["secret"]; string redirect_uri = ConfigurationManager.AppSettings["redirect_uri"]; //code = Request.QueryString["code"].ToString(); WebUtils webUtils = new WebUtils(); IDictionary<string, string> pout = new Dictionary<string, string>(); pout.Add("grant_type", "authorization_code"); pout.Add("client_id", appkey); pout.Add("client_secret", secret); pout.Add("code", code); pout.Add("redirect_uri", redirect_uri); // 沙箱 string output = webUtils.DoPost("https://oauth.tbsandbox.com/token", pout); // 正式 //string output = webUtils.DoPost("https://oauth.taobao.com/token", pout); cbModel cbmodel = js.Deserialize<cbModel>(output); // Access token string sessionKey = cbmodel.access_token; // Access token过期时间 long expires_in = cbmodel.expires_in; Application["SessionKey"] = sessionKey; Application["ExpiresIn"] = expires_in; } } }
- 2 回答
- 0 关注
- 976 浏览
添加回答
举报
0/150
提交
取消