net/c# 微信企业号 userid转换成openid接口
2017-02-04 09:45
441 查看
#region 方法 GetQiyConvertToUserid(string accesstoken, string strOpenId) openid转换成userid接口
/// <summary>
///
/// </summary>
/// <param name="accesstoken"></param>
/// <param name="strOpenId"></param>
/// <returns></returns>
public string GetQiyConvertToUserid(string accesstoken, string strOpenId)
{
TWeixinHelper weihelper = new TWeixinHelper();
string weixin = "{\"openid\": \"" + strOpenId + "\"}";
string to = weihelper.GetPage("https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid?access_token=" + accesstoken, weixin);
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="accesstoken"></param>
/// <param name="strOpenId"></param>
/// <returns></returns>
public string GetQiyConvertToUserid(string accesstoken, string strOpenId)
{
TWeixinHelper weihelper = new TWeixinHelper();
string weixin = "{\"openid\": \"" + strOpenId + "\"}";
string to = weihelper.GetPage("https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid?access_token=" + accesstoken, weixin);
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# 微信企业号 userid转换成openid接口
- NET/C# 微信企业号获取Userid
- C#工程转换成VB.net工程
- C#.NET 中的类型转换
- 看到 转换DotNetNuke为C#版 的文章
- [转]VB.net C# 代码转换工具
- C#.net 中将位图文件转换成为Icon的简单方法
- vb.net与c#相互转换工具
- 一个把C#代码转换成VB.NET代码的网页
- C#.NET 中的类型转换(转自eric的Blog)
- .Net/C#/VB/T-SQL/Java 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- VB.net 跟 C# 的代码转换
- 也谈C#转换为VB.NET
- C#和VB.NET代码互相转换工具
- 引用---VB.NET与C#之间的转换
- .Net/C#/VB/T-SQL/Java/Script 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- 使用Web服务将C#代码转换为VB.NET代码
- C#.NET 中的类型转换[收藏]
- 利用SharpDevelop做C#与vb.net代码转换很好
- 转 .Net/C#/VB/T-SQL/Java/Script 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)