username@email.com
2024-09-09 cc170291673472d3cda8d7ea77f6bd3a3b5dbb83
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using CoreCms.Net.Caching.AccressToken;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.WeChat.Service.HttpClients;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SKIT.FlurlHttpClient.Wechat.Api.Models;
using System.Threading.Tasks;
using SKIT.FlurlHttpClient.Wechat.Api;
using CoreCms.Net.Model.WeChatEntites;
 
namespace CoreCms.Net.Web.WebApi.Controllers
{
    /// <summary>
    /// 小程序内置直播功能
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LiveBroadCastController : ControllerBase
    {
        private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
 
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="weChatApiHttpClientFactory"></param>
        public LiveBroadCastController(IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
        {
            _weChatApiHttpClientFactory = weChatApiHttpClientFactory;
        }
 
 
        #region 获取直播间列表和回放
        /// <summary>
        /// 获取直播间列表和回放
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<WebApiCallBack> GetLiveInfo([FromBody] FMPageByIntId entity)
        {
            var jm = new WebApiCallBack();
 
            var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
            var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
 
            var request = new MyWxaBusinessGetLiveInfoRequest
            {
                AccessToken = accessToken,
                Limit = entity.limit,
                Offset = (entity.page - 1) * entity.limit,
                Action = !string.IsNullOrEmpty(entity.where) ? "get_replay" : ""
            };
 
            var response = await client.ExecuteWxaBusinessGetLiveInfoAsync(request);
            if (response.IsSuccessful())
            {
                jm.status = true;
                jm.data = response;
            }
            else
            {
                jm.status = false;
                jm.msg = response.ErrorCode == 9410000 ? "暂无直播信息" : response.ErrorMessage;
                jm.otherData = response;
            }
            return jm;
        }
        #endregion
 
 
 
 
    }
}