MemberApi.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5. except in compliance with the License. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed under the
  8. License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  9. either express or implied. See the License for the specific language governing permissions
  10. and limitations under the License.
  11. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
  12. ----------------------------------------------------------------*/
  13. #endregion Apache License Version 2.0
  14. /*----------------------------------------------------------------
  15. Copyright (C) 2019 Senparc
  16. 文件名:MemberApi.cs
  17. 文件功能描述:获取用户信息Api
  18. 创建标识:Senparc - 20150319
  19. ----------------------------------------------------------------*/
  20. using System.Collections.Generic;
  21. using Senparc.Weixin.HttpUtility;
  22. namespace Senparc.Weixin.MP.AppStore.Api
  23. {
  24. public class MemberApi : BaseApi
  25. {
  26. public MemberApi(Passport passport)
  27. : base(passport)
  28. {
  29. }
  30. private GetMemberResult GetMemberFunc(int weixinId, string openId)
  31. {
  32. var url = _passport.ApiUrl + "GetMember";
  33. var formData = new Dictionary<string, string>();
  34. formData["token"] = _passport.Token;
  35. formData["openid"] = openId;
  36. formData["weixinId"] = weixinId.ToString();
  37. var result = CO2NET.HttpUtility.Post.PostGetJson<GetMemberResult>(url, formData: formData);
  38. return result;
  39. }
  40. /// <summary>
  41. /// 获取用户信息
  42. /// </summary>
  43. /// <returns></returns>
  44. public GetMemberResult GetMember(int weixinId, string openId)
  45. {
  46. return ApiConnection.Connection(() => GetMemberFunc(weixinId, openId)) as GetMemberResult;
  47. }
  48. }
  49. }