Web开发中常常会用到需要微信授权,充值、和提现功能,这篇主要讲的是登录授权,话不多说,开始。
微信网页授权文档(建议先看一遍对流程有个大致的认识):微信公众号开发文档—网页授权
注意事项:
请求需要AppId、AppSecret(填自己公众号的即可)
string code = Request.QueryString["code"];
//你的回发地址
string redirect_uri = "http://www.xxxx.com";
if (string.IsNullOrEmpty(code))
{
string code_url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_userinfo&state=lk#wechat_redirect", AppId, redirect_uri);
//回发后会自带code参数
Response.Redirect(code_url);
return;
}
else
{
//获得code后执行..
}
2 <