protected void Page_Load(object sender, EventArgs e) { var api = Request["Api"]; if (String.IsNullOrEmpty(api)) { return; } var manager = new OAuthHelper(ConfigurationManager.AppSettings["wxappid"]); var url = manager.BuildOAuthUrl("http://wx.taogame.com/OAuthUserInfoDemo.aspx", api == "snsapi_base" ? OAuthScope.Base : OAuthScope.UserInfo, api); QrEncoder encoder = new QrEncoder(ErrorCorrectionLevel.M); QrCode qrCode; encoder.TryEncode(url, out qrCode); GraphicsRenderer gRenderer = new GraphicsRenderer( new FixedModuleSize(2, QuietZoneModules.Two), Brushes.Black, Brushes.White); MemoryStream ms = new MemoryStream(); gRenderer.WriteToStream(qrCode.Matrix, ImageFormat.Jpeg, ms); Response.BinaryWrite(ms.ToArray()); }
public void ProcessRequest(HttpContext context) { var manager = new OAuthHelper(wxappid); var return_url = context.Request["return_url"] ?? ""; var url = manager.BuildOAuthUrl(HttpUtility.UrlEncode(wx_auth), OAuthScope.UserInfo, HttpUtility.UrlEncode(return_url)); context.Response.Redirect(url); }
protected void Button1_Click(object sender, EventArgs e) { if (DropDownList1.SelectedValue != "0") { Image1.ImageUrl = "~/Qrcodepage.aspx?api=" + DropDownList1.SelectedValue; Image1.Visible = true; var manager = new OAuthHelper(ConfigurationManager.AppSettings["wxappid"]); var url = manager.BuildOAuthUrl("http://wx.taogame.com/OAuthUserInfoDemo.aspx", DropDownList1.SelectedValue == "snsapi_base" ? OAuthScope.Base : OAuthScope.UserInfo, DropDownList1.SelectedValue); Label1.Text = url; } else { Image1.Visible = false; Label1.Visible = true; } }
public void BuildOAuthUrlScopeUserInfoTest() { var oauth = new OAuthHelper("wx7fc05579394bd02c"); Console.WriteLine(oauth.BuildOAuthUrl("http://wx.taogame.com/OAuth2Demo.aspx", WX.Model.OAuthScope.UserInfo, "123123")); }