AutoBind.cshtml.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using JCSoft.WX.Framework.Api;
  6. using JCSoft.WX.Framework.Models.ApiRequests;
  7. using JCSoft.WX.Framework.Models.ApiResponses;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. namespace SupplierWeb.Pages
  11. {
  12. public class AutoBindModel : PageModel
  13. {
  14. private readonly IApiClient _client;
  15. public AutoBindModel(IApiClient apiClient)
  16. {
  17. _client = apiClient;
  18. }
  19. private const string _appId = "wxdc3ee459a9b8f109";
  20. private const string _appSecret = "9e18517ce82628615105213ce463f1d2";
  21. public void OnGet([FromQuery]string code)
  22. {
  23. if (!String.IsNullOrWhiteSpace(code))
  24. {
  25. AccessTokenCode = _client.Execute(new AccessTokenCodeRequest
  26. {
  27. AppId = _appId,
  28. AppSecret = _appSecret,
  29. Code = code
  30. });
  31. }
  32. }
  33. public AccessTokenCodeResponse AccessTokenCode { get; set; }
  34. }
  35. }