public WeiboClient(string appKey, string appSecret, string redirectUrl) { AppKey = appKey; AppSecret = appSecret; RedirectUrl = ApiUtils.GetAuthRedirectUrl(OAuthType.Weibo, redirectUrl); }
public QqClient(string appId, string appKey, string redirectUrl) { AppId = appId; AppKey = appKey; RedirectUrl = ApiUtils.GetAuthRedirectUrl(OAuthType.Qq, redirectUrl); }
public static string Parse(IParseContext context) { var type = string.Empty; var redirectUrl = string.Empty; ParseUtils.RegisterBodyHtml(context); var stlAnchor = new HtmlAnchor(); foreach (var name in context.StlAttributes.AllKeys) { var value = context.StlAttributes[name]; if (Utils.EqualsIgnoreCase(name, AttributeType)) { type = Context.ParseApi.ParseAttributeValue(value, context); } else if (Utils.EqualsIgnoreCase(name, AttributeRedirectUrl)) { redirectUrl = Context.ParseApi.ParseAttributeValue(value, context); } else { stlAnchor.Attributes.Add(name, value); } } if (string.IsNullOrEmpty(redirectUrl)) { redirectUrl = Context.ParseApi.GetCurrentUrl(context); } string text; var url = string.Empty; var onClick = string.Empty; if (Utils.EqualsIgnoreCase(type, OAuthType.Weibo.Value)) { text = "微博登录"; url = $"{ApiUtils.GetAuthUrl(OAuthType.Weibo)}?redirectUrl={HttpUtility.UrlEncode(redirectUrl)}"; } else if (Utils.EqualsIgnoreCase(type, OAuthType.Weixin.Value)) { text = "微信登录"; url = $"{ApiUtils.GetAuthUrl(OAuthType.Weixin)}?redirectUrl={HttpUtility.UrlEncode(redirectUrl)}"; } else if (Utils.EqualsIgnoreCase(type, OAuthType.Qq.Value)) { text = "QQ登录"; url = $"{ApiUtils.GetAuthUrl(OAuthType.Qq)}?redirectUrl={HttpUtility.UrlEncode(redirectUrl)}"; } else if (Utils.EqualsIgnoreCase(type, TypeAll)) { text = "一键登录"; onClick = ParseUtils.OnClickLoginAll; } else { text = "登录"; onClick = ParseUtils.OnClickLogin; } stlAnchor.HRef = string.IsNullOrEmpty(url) ? "javascript:;" : url; if (!string.IsNullOrEmpty(onClick)) { stlAnchor.Attributes.Add("onclick", onClick); } stlAnchor.InnerHtml = Context.ParseApi.Parse(context.StlInnerHtml, context); if (string.IsNullOrWhiteSpace(stlAnchor.InnerHtml)) { stlAnchor.InnerHtml = text; } return(Utils.GetControlRenderHtml(stlAnchor)); }
public WeixinClient(string appId, string appSecret, string redirectUrl) { AppId = appId; AppSecret = appSecret; RedirectUrl = ApiUtils.GetAuthRedirectUrl(OAuthType.Weixin, redirectUrl); }