Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加微信运动步数解密 #1671

Merged
merged 3 commits into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*----------------------------------------------------------------

文件名:DecodedRunData.cs
文件功能描述:用户运动步数解密类


创建标识:2019-03-28
----------------------------------------------------------------*/

using Senparc.Weixin.WxOpen.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Senparc.Weixin.MP.Sample.Models
{
// "stepInfoList": [
// {
// "timestamp": 1445866601,
// "step": 100
// },
// {
// "timestamp": 1445876601,
// "step": 120
// }
//]
[Serializable]
public class DecodedRunData : DecodeEntityBase
{
public List<stepModel> stepInfoList { get; set; }
}

public class stepModel
{
public long timestamp { get; set; }
public long step { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ and limitations under the License.
#endif
using Senparc.Weixin.Exceptions;
using Senparc.Weixin.Helpers;
using Senparc.Weixin.MP.Sample.Models;
using Senparc.Weixin.WxOpen.Containers;
using Senparc.Weixin.WxOpen.Entities;

Expand Down Expand Up @@ -243,7 +244,24 @@ public static DecodedPhoneNumber DecryptPhoneNumber(string sessionId, string enc
return phoneNumber;

}

/// <summary>
/// 解密微信运动步数
/// </summary>
/// <param name="sessionId"></param>
/// <param name="encryptedData"></param>
/// <param name="iv"></param>
/// <returns></returns>
public static DecodedRunData DecodedRunDataBySessionid(string sessionId, string encryptedData, string iv)
{
var jsonStr = EncryptHelper.DecodeEncryptedDataBySessionId(sessionId, encryptedData, iv);
#if NET45
JavaScriptSerializer js = new JavaScriptSerializer();
var rundateInfo = js.Deserialize<DecodedRunData>(jsonStr);
#else
var rundateInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DecodedRunData>(jsonStr);
#endif
return rundateInfo;
}
/// <summary>
/// 检查解密消息水印
/// </summary>
Expand Down