public async Task <Result <WeChatUserAccessToken> > GetOpenPlatformUserAccessTokenAsync(string code) { _options.RequireOpenPlatformSettings(); return(await GetUserAccessTokenAsync(code, new WeChatAppIdSecret { AppId = _options.OpenPlatformAppId, AppSecret = _options.OpenPlatformAppSecret })); }
public string CreateWebQrCodeLoginScript(string redirectUrl, string styleSheetUrl) { _options.RequireOpenPlatformSettings(); var elementId = "_" + Crypto.RandomString(); var html = @"<div id='" + elementId + @"'></div> <script type='text/javascript' src='https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js'></script> <script type='text/javascript'> (function loadWxLogin() { if (typeof WxLogin !== 'function') { setTimeout(loadWxLogin, 50); } else { var obj = new WxLogin({ self_redirect: false, scope: 'snsapi_login', id: '" + elementId + @"', appid: '" + _options.OpenPlatformAppId + @"', redirect_uri: '" + redirectUrl + @"', state: '" + Crypto.Encrypt(DateTime.Now.ToString("yyyy-M-d H:mm:ss"), iv: _options.OpenPlatformAppId !) + @"', href: '" + styleSheetUrl + @"', style: '' }); } })(); </script>" ; return(html); }