Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dfd4cbd
Showing
40 changed files
with
4,345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
bin/ | ||
obj/ | ||
*.suo | ||
/*.suo | ||
*.nupkg | ||
*.nuspec.txt | ||
*.nuspec | ||
NuGet.exe | ||
*.scc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#region << 版 本 注 释 >> | ||
/**************************************************** | ||
* 文 件 名:CreateQRCode | ||
* Copyright(c) 青之软件 | ||
* CLR 版本: 4.0.30319.17929 | ||
* 创 建 人:ITdos | ||
* 电子邮箱:admin@itdos.com | ||
* 创建日期:2015/1/4 10:43:50 | ||
* 文件描述: | ||
****************************************************** | ||
* 修 改 人: | ||
* 修改日期: | ||
* 备注描述: | ||
*******************************************************/ | ||
#endregion | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Web.Caching; | ||
using Dos.Common; | ||
using Dos.WeChat.Common; | ||
using Dos.WeChat.Model; | ||
|
||
namespace Dos.WeChat | ||
{ | ||
public class QrCode | ||
{ | ||
|
||
/// <summary> | ||
/// 创建二维码。 | ||
/// </summary> | ||
/// <param name="msg"></param> | ||
/// <returns></returns> | ||
public QrResult CreateTempQrCode(CreateQrCode msg) | ||
{ | ||
var result = HttpHelper.Post<QrResult>(ApiList.QrcodeCreateUrl, msg.ToString(), "access_token=" + Token.GetAccessToken(msg)); | ||
return result; | ||
} | ||
/// <summary> | ||
/// 传入ExpireSeconds,ActionName,ActionInfo(sceneId)。获取临时二维码,返回二维码图片文件的服务器地址。 | ||
/// </summary> | ||
/// <param name="msg"></param> | ||
/// <returns></returns> | ||
public Stream GetTempQrCode(CreateQrCode msg) | ||
{ | ||
msg.ActionName = EnumHelper.QrCodeType.QR_SCENE.ToString(); | ||
var result = HttpHelper.Post<QrResult>(ApiList.QrcodeCreateUrl, msg.ToString(), "access_token=" + Token.GetAccessToken(msg)); | ||
var url = ApiList.ShowQrcodeUrl + "?ticket=" + result.Ticket + "&access_token=" + Token.GetAccessToken(msg); | ||
var stream = HttpHelper.GetStream(url,""); | ||
return stream; | ||
} | ||
/// <summary> | ||
/// 传入ActionName,ActionInfo(scene_id对应QR_LIMIT_SCENE,scene_str对应QR_LIMIT_STR_SCENE) | ||
/// </summary> | ||
/// <param name="msg"></param> | ||
/// <returns></returns> | ||
public Stream GetEverQrCode(CreateQrCode msg) | ||
{ | ||
var result = HttpHelper.Post<QrResult>(ApiList.QrcodeCreateUrl, msg.ToString(), | ||
"access_token=" + Token.GetAccessToken(msg)); | ||
var url = ApiList.ShowQrcodeUrl + "?ticket=" + result.Ticket + "&access_token=" + Token.GetAccessToken(msg); | ||
var stream = HttpHelper.GetStream(url, ""); | ||
return stream; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#region << 版 本 注 释 >> | ||
/**************************************************** | ||
* 文 件 名:EntrySign | ||
* Copyright(c) 青之软件 | ||
* CLR 版本: 4.0.30319.17929 | ||
* 创 建 人:ITdos | ||
* 电子邮箱:admin@itdos.com | ||
* 创建日期:2014/10/25 11:21:51 | ||
* 文件描述: | ||
****************************************************** | ||
* 修 改 人: | ||
* 修改日期: | ||
* 备注描述: | ||
*******************************************************/ | ||
#endregion | ||
using System; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Configuration; | ||
using System.Web.Security; | ||
using Dos.WeChat.Model; | ||
|
||
namespace Dos.WeChat | ||
{ | ||
/// <summary> | ||
/// 接入验证 | ||
/// </summary> | ||
public class JoinToken | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public string signature { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public string timestamp { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public string nonce { get; set; } | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public string echostr { get; set; } | ||
private static void ParseProperties(JoinToken es,HttpContextBase hcb = null) | ||
{ | ||
if (es == null) | ||
return; | ||
|
||
var ps = es.GetType().GetProperties(); | ||
foreach (var p in ps) | ||
{ | ||
if (hcb == null) | ||
{ | ||
var context = HttpContext.Current; | ||
if (context == null) | ||
return; | ||
p.SetValue(es, context.Request[p.Name], null); | ||
} | ||
else | ||
{ | ||
p.SetValue(es, hcb.Request[p.Name], null); | ||
} | ||
} | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static bool IsGetRequest(HttpContextBase context = null) | ||
{ | ||
if (context == null) | ||
{ | ||
return HttpContext.Current.Request.HttpMethod == "GET"; | ||
} | ||
else | ||
{ | ||
return context.Request.HttpMethod == "GET"; | ||
} | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static bool IsSignatureRequest() | ||
{ | ||
return string.IsNullOrEmpty(HttpContext.Current.Request["signature"]); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static JoinToken ParseJoinToken(HttpContextBase context = null) | ||
{ | ||
var result = new JoinToken(); | ||
ParseProperties(result, context); | ||
return result; | ||
} | ||
/// <summary> | ||
/// 验证签名 | ||
/// </summary> | ||
public bool Check(WeChatParam param = null) | ||
{ | ||
var token = GetConfig.GetToken(param); | ||
var vs = new[] { timestamp, nonce, token }.OrderBy(s => s); | ||
var str = string.Join("", vs); | ||
var copu = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1"); | ||
if (copu == null) | ||
{ | ||
return false; | ||
} | ||
return copu.Equals(signature, StringComparison.CurrentCultureIgnoreCase); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public void Response(HttpContextBase context = null) | ||
{ | ||
if (context == null) | ||
{ | ||
var response = HttpContext.Current.Response; | ||
response.Write(echostr ?? "echostr is null"); | ||
response.Flush(); | ||
response.Close(); | ||
} | ||
else | ||
{ | ||
var response = context.Response; | ||
response.Write(echostr ?? "echostr is null"); | ||
response.Flush(); | ||
response.Close(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.