资源简介
入口页面: wxProcess.aspx
【自己调通了非常喜悦。好东东,大家分享。 免积分,给个好评哦;)】
微信公众平台 网页授权获取用户基本信息
//获取从wxProcess.aspx传递过来的跳转地址reurl
if (Request.QueryString["reurl"] != null && Request.QueryString["reurl"] != "")
{
reurl = Request.QueryString["reurl"].ToString();
}
string code = "";
if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
{
//获取微信回传的code
code = Request.QueryString["code"].ToString();
OAuth_Token Model = Get_token(code); //获取token
OAuthUser OAuthUser_Model = Get_UserInfo(Model.access_token, Model.openid );
if(OAuthUser_Model.openid!=null && OAuthUser_Model.openid !="") //已获取得openid及其他信息
{
//在页面上输出用户信息
Response.Write("用户OPENID:" + OAuthUser_Model.openid + "用户昵称:" + OAuthUser_Model.nickname + "性别:" + OAuthUser_Model.sex + "所在省:" + OAuthUser_Model.province + "所在市:" + OAuthUser_Model.city + "所在国家:" + OAuthUser_Model.country + "头像地址:" + OAuthUser_Model.headimgurl + "用户特权信息:" + OAuthUser_Model.privilege);
//或跳转到自己的页面,想怎么处理就怎么处理
Response.Redirect(reurl);
}
}

代码片段和文件信息
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.Runtime.Serialization.Json;
using System.IO;
namespace GustBook.WEB.front.html.CommonControl
{
public partial class wxProcess1 : System.Web.UI.Page
{
protected void Page_Load(object sender EventArgs e)
{
if (!IsPostBack)
{
// 测试号信息
//appID
//wx81b71d9e6fcb9dd8
//appsecret
//1b7fb028c223d1d7283946ee8b52ee4b
// TTK
// wxfef3c2c5833330ea
//AppSecret(应用密钥)a808ad45e740c0fa04fc1ca2579b83b5 隐藏 重置
string reurl = ““;
//传递参数,获取用户信息后,可跳转到自己定义的页面,想怎么处理就怎么处理
if (Request.QueryString[“reurl“] != null && Request.QueryString[“reurl“] != ““)
{
reurl = Request.QueryString[“reurl“].ToString();
}
else
{
reurl = “http://www.dreamlinker.cn“;
}
string code = ““;
//弹出授权页面(如在不弹出授权页面基础下未获得openid,弹出授权页面,提示用户授权)
if (Request.QueryString[“auth“] != null && Request.QueryString[“auth“] != ““ && Request.QueryString[“auth“] == “1“)
{
Response.Redirect(“https://open.weixin.qq.com/connect/oauth2/authorize?appid=“ + “wxfef3c2c5833330ea“ + “&redirect_uri=http://www.dreamlinker.cn/wxProcess2.aspx?reurl=“ + reurl + “&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect“);
}
else
{
//不弹出授权页面
Response.Redirect(“https://open.weixin.qq.com/connect/oauth2/authorize?appid=“ + “wxfef3c2c5833330ea“ + “&redirect_uri=http://www.dreamlinker.cn/wxProcess2.aspx?reurl=“ + reurl + “&response_type=code&scope=snsapi_base&state=1#wechat_redirect“);
// https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=http%3A%2F%2Fnba.bluewebgame.com%2Foauth_response.php&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
}
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 369 2016-02-27 00:17 wxProcess.aspx
文件 2646 2016-03-01 23:21 wxProcess.aspx.cs
....... 795 2016-02-27 00:17 wxProcess.aspx.designer.cs
....... 371 2016-02-27 00:17 wxProcess2.aspx
文件 11281 2016-03-02 09:25 wxProcess2.aspx.cs
....... 796 2016-02-27 00:17 wxProcess2.aspx.designer.cs
----------- --------- ---------- ----- ----
16258 6
- 上一篇:C#做一个悬浮窗口程序
- 下一篇:实现自定义的Web服务器(C#)
相关资源
- 微信公众平台网页授权获取用户基本
- 最新微信公众平台源码 C# ASP.NET 微商
- C#微信公众平台开发源码.rar
- ASP.NET微信公众平台开发源代码
- C# 实现微信公众平台接口消息收发D
- asp.net 实现微信公众平台的主动推送信
- C#微信公众平台开发实用类库
- ASP.NET网页微信登录授权获取用户基本
- C# 微信公众平台开发.NET源码
- 微信 网页授权获取用户基本信息(
- 微信公众平台消息接口c#版
- 支付宝 网页授权 获取用户信息Demo(
- 微信公众平台开发c#框架(含发消息
- c#微信公众平台源代码
- C#微信公众平台开发(SDK类库完整源码
- 微信企业号授权获取用户信息
- asp.net实现微信公众平台的主动推送信
- 微信公众平台demo三层webForm
- C#微信公众平台二次开发
- C# 模拟登陆QQ空间并获取用户资料(支
- 微信公众平台获取用户openid c# asp.ne
评论
共有 条评论