mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:23:26 +08:00
【新增】增加微信小程序私域直播功能。增加后台开关
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
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;
|
||||
|
||||
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 WxaBusinessGetLiveInfoRequest
|
||||
{
|
||||
AccessToken = accessToken,
|
||||
Limit = entity.limit,
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user