mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🐛【企业微信】修复创建预约直播活动详情参数取值问题
This commit is contained in:
parent
f3921c7332
commit
6f776bdda0
@ -84,7 +84,7 @@ public interface WxCpLivingService {
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/create?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param request 创建预约直播请求参数.
|
||||
* @return
|
||||
* @return livingId(直播id)
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
String livingCreate(WxCpLivingCreateRequest request) throws WxErrorException;
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.chanjar.weixin.cp.bean.living;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建预约直播请求.
|
||||
@ -57,10 +55,12 @@ public class WxCpLivingCreateRequest implements Serializable {
|
||||
@SerializedName("activity_detail")
|
||||
private ActivityDetail activityDetail;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ActivityDetail implements Serializable {
|
||||
|
||||
@SerializedName("image_list")
|
||||
private String[] imageList;
|
||||
private List<String> imageList;
|
||||
|
||||
@SerializedName("description")
|
||||
private String description;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.chanjar.weixin.cp.api;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
|
||||
import me.chanjar.weixin.cp.bean.living.*;
|
||||
@ -10,6 +11,7 @@ import org.eclipse.jetty.util.ajax.JSON;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -34,6 +36,46 @@ public class WxCpLivingTest {
|
||||
wxCpService = new WxCpServiceImpl();
|
||||
wxCpService.setWxCpConfigStorage(config);
|
||||
|
||||
/**
|
||||
* 测试创建直播
|
||||
*/
|
||||
WxCpLivingCreateRequest createRequest = new WxCpLivingCreateRequest();
|
||||
createRequest.setAnchorUserid("WangKai");
|
||||
createRequest.setTheme("直播1");
|
||||
|
||||
long currentTimeMillis = System.currentTimeMillis() + 3600000L;
|
||||
createRequest.setLivingStart(currentTimeMillis);
|
||||
createRequest.setLivingDuration(3600L);
|
||||
createRequest.setType(4);
|
||||
createRequest.setDescription("这是通用直播1");
|
||||
|
||||
val activityDetail = new WxCpLivingCreateRequest.ActivityDetail();
|
||||
activityDetail.setDescription("活动描述,非活动类型的直播不用传");
|
||||
|
||||
// String[] strings = new String[]{"MEDIA_ID_2", "MEDIA_ID_1"};
|
||||
ArrayList imageList = new ArrayList();
|
||||
imageList.add("MEDIA_ID_1");
|
||||
imageList.add("MEDIA_ID_2");
|
||||
|
||||
activityDetail.setImageList(imageList);
|
||||
createRequest.setActivityDetail(activityDetail);
|
||||
|
||||
String livingCreate = wxCpService.getLivingService().livingCreate(createRequest);
|
||||
log.info("返回的直播id为:{}", livingCreate);
|
||||
|
||||
WxCpLivingCreateRequest thisReq = WxCpLivingCreateRequest.fromJson(createRequest.toJson());
|
||||
log.info("返回的数据:{}", thisReq.toJson());
|
||||
|
||||
// 创建预约直播
|
||||
String createJson = "{\"anchor_userid\":\"ChenHu\",\"theme\":\"theme\",\"living_start\":164037820420,\"living_duration\":3600,\"description\":\"test description\",\"type\":4,\"remind_time\":60,\"activity_cover_mediaid\":\"MEDIA_ID\",\"activity_share_mediaid\":\"MEDIA_ID\",\"activity_detail\":{\"description\":\"活动描述,非活动类型的直播不用传\",\"image_list\":[\"xxxx1\",\"xxxx1\"]}}";
|
||||
WxCpLivingCreateRequest requestData = WxCpLivingCreateRequest.fromJson(createJson);
|
||||
String thisLivingId = wxCpService.getLivingService().livingCreate(requestData);
|
||||
log.info("livingId为:{}", thisLivingId);
|
||||
|
||||
|
||||
/**
|
||||
* other api
|
||||
*/
|
||||
String livingCode = wxCpService.getLivingService().getLivingCode("o50by5NezHciWnoexJsrI49ILNqI", "lvOQpTDwAAD2MYuOq9y_bmLNMJfbbdGw");
|
||||
log.info(JSON.toString(livingCode));
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class WxCpGroupRobotServiceImplTest {
|
||||
@Test
|
||||
public void testSendNews() throws WxErrorException {
|
||||
NewArticle article = new NewArticle("图文消息测试", "hello world", "http://www.baidu.com",
|
||||
"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png", null);
|
||||
"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png", null, null, null);
|
||||
robotService.sendNews(Stream.of(article).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user