NET/C# 微信企业号获取Userid
2017-02-04 09:05
375 查看
#region 方法 GetQiyAccess_token(string appid, string appsecret) 调用网页 Access_token
/// <summary>
///
/// </summary>
/// <param name="appid"></param>
/// <param name="appsecret"></param>
/// <returns></returns>
public string GetQiyAccess_token(string appid, string appsecret)
{
TWeixinHelper weihelper = new TWeixinHelper();
string to = weihelper.GetData("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + appid + "&corpsecret=" + appsecret);
string access_token = "";
string strCode = @"\""access_token\"":\s*""(?'access_token'[^""]*)""";
Regex regex = new Regex(strCode, RegexOptions.IgnoreCase);
if (regex.IsMatch(to))
{
MatchCollection matches = regex.Matches(to);
StringBuilder stringBuilder = new StringBuilder();
foreach (Match match in matches)
{
access_token = match.Groups["access_token"].Value;
}
}
return access_token;
}
#endregion
#region 方法 GetQiyGetUserinfo(string accesstoken, string code) 调用网页 获取用户id
/// <summary>
/// 调用网页 Access_token
/// </summary>
/// <param name="appid"></param>
/// <param name="appsecret"></param>
/// <param name="CODE"></param>
/// <returns></returns>
public string GetQiyGetUserinfo(string accesstoken, string code)
{
TWeixinHelper weihelper = new TWeixinHelper();
string to = weihelper.GetData("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + accesstoken + "&code=" + code);
string strUserId = "";
string strCode = @"\""UserId\"":\s*""(?'UserId'[^""]*)""";
Regex regex = new Regex(strCode, RegexOptions.IgnoreCase);
if (regex.IsMatch(to))
{
MatchCollection matches = regex.Matches(to);
StringBuilder stringBuilder = new StringBuilder();
foreach (Match match in matches)
{
strUserId = match.Groups["UserId"].Value;
}
}
return strUserId;
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="appid"></param>
/// <param name="appsecret"></param>
/// <returns></returns>
public string GetQiyAccess_token(string appid, string appsecret)
{
TWeixinHelper weihelper = new TWeixinHelper();
string to = weihelper.GetData("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + appid + "&corpsecret=" + appsecret);
string access_token = "";
string strCode = @"\""access_token\"":\s*""(?'access_token'[^""]*)""";
Regex regex = new Regex(strCode, RegexOptions.IgnoreCase);
if (regex.IsMatch(to))
{
MatchCollection matches = regex.Matches(to);
StringBuilder stringBuilder = new StringBuilder();
foreach (Match match in matches)
{
access_token = match.Groups["access_token"].Value;
}
}
return access_token;
}
#endregion
#region 方法 GetQiyGetUserinfo(string accesstoken, string code) 调用网页 获取用户id
/// <summary>
/// 调用网页 Access_token
/// </summary>
/// <param name="appid"></param>
/// <param name="appsecret"></param>
/// <param name="CODE"></param>
/// <returns></returns>
public string GetQiyGetUserinfo(string accesstoken, string code)
{
TWeixinHelper weihelper = new TWeixinHelper();
string to = weihelper.GetData("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + accesstoken + "&code=" + code);
string strUserId = "";
string strCode = @"\""UserId\"":\s*""(?'UserId'[^""]*)""";
Regex regex = new Regex(strCode, RegexOptions.IgnoreCase);
if (regex.IsMatch(to))
{
MatchCollection matches = regex.Matches(to);
StringBuilder stringBuilder = new StringBuilder();
foreach (Match match in matches)
{
strUserId = match.Groups["UserId"].Value;
}
}
return strUserId;
}
#endregion
相关文章推荐
- net/c# 微信企业号获取用户信息判断是否关注企业号
- NET/C# 微信企业号开发获取AccessToken
- net/c# 微信企业号 userid转换成openid接口
- net/c# 微信企业号 userid转换成openid接口
- ASP.NET获取IP与MAC[using C#]
- [导入]ASP.NET获取IP与MAC[using C#]
- ASP.NET(c#)运用API函数获取系统信息
- (转).Net/C# 获取字节流编码
- ADO.net 里面获取返回值的方法为(c#):
- 获取本机已安装的软件列表C#/VB.NET(Get the list of installed software in local pc)
- 获取汉字第一个拼音 c# asp.net 2.0
- ASP.NET获取IP与MAC[using C#]
- c# asp.net 2.0 获取汉字第一个拼音
- [C#.Net]利用HttpRequest登录到某个网站,然后获取网站信息的程序示例
- .Net(C#)获取AD用户信息的示例代码
- 终于找到ASP.NET c# 简单的获取远端文件的方法!
- ASP.NET(C#)获取客户端的网卡MAC代码
- aspx.net C# 获取或设置前台元素值
- ASP.NET获取IP与MAC[using C#]
- .NET Compact Framework 1.x 获取SD卡路径, C#