基本信息
源码名称:微信企业号授权获取用户信息
源码大小:5.58KB
文件格式:.rar
开发语言:C#
更新时间:2016-03-13
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using SWX.Utils; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using WeiPay; public partial class mobile_index : System.Web.UI.Page { public string code = ""; public string UserId = ""; public string userstart = ""; public string access_token = ""; SqlData sql = new SqlData(); protected void Page_Load(object sender, EventArgs e) { bindata(); } void bindata() { if (string.IsNullOrEmpty(Request.QueryString["code"])) { string code_url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid=*****&redirect_uri=&response_type=code&scope=SCOPE&state=STATE#wechat_redirect"); Response.Redirect(code_url); } else { code = Request.QueryString["code"]; LogUtil.WriteLog("============ 授权开始 ==============="); LogUtil.WriteLog("code" code); string access_tokenjson = HttpRequestUtil.RequestUrl(string.Format("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=&corpsecret=")); LogUtil.WriteLog("access_tokenjson" access_tokenjson); access_token = Tools.GetJsonValue(access_tokenjson, "access_token"); LogUtil.WriteLog("access_token" access_token); string infojson = HttpRequestUtil.RequestUrl(string.Format("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" access_token "&code=" code "")); LogUtil.WriteLog("infojson" infojson); UserId = Tools.GetJsonValue(infojson, "UserId"); LogUtil.WriteLog("UserId" UserId); string OpenId = Tools.GetJsonValue(infojson, "OpenId"); if (!string.IsNullOrEmpty(OpenId)) { Response.Write("<div style='text-align:center; fong-size:14px'>您还不是该企业号的成员</div>"); Response.End(); } string userjson = HttpRequestUtil.RequestUrl(string.Format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" access_token "&userid=" UserId "")); userstart = Tools.GetJsonValue(userjson, "status"); if (userstart == "2") { Response.Write("您的账号已被管理员冻结"); Response.End(); } if (userstart == "3") { Response.Write("您还没有关注该企业号"); Response.End(); } DataRow dr = sql.ExecuteDateRow("select * from user1 where u_userId='" UserId "'"); if (dr != null) { Session["member_id"] = dr["u_id"]; Session["member_username"] = dr["u_yhm"]; Response.Redirect("m_info.aspx"); } else { Response.Write("您的微信还没有绑定酒店账号"); Response.End(); } } } } public class yqInfo { }