Skip to content

Commit

Permalink
🎨 #2785【小程序】获取直播间分享二维码接口优化,支持分享路径和海报
Browse files Browse the repository at this point in the history
  • Loading branch information
linlinjava authored and binarywang committed Aug 21, 2022
1 parent c78a1f5 commit 0f9e75a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public interface WxMaLiveService {
* @return .
* @throws WxErrorException .
*/
String getSharedCode(Integer roomId, String params) throws WxErrorException;
WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException;

/**
* 获取直播房间列表.(分页)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String getPushUrl(Integer roomId) throws WxErrorException {
}

@Override
public String getSharedCode(Integer roomId, String params) throws WxErrorException {
public WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException {
Map<String, Object> map = new HashMap<>(2);
map.put(ROOM_ID, roomId);
if (null != params) {
Expand All @@ -98,7 +98,7 @@ public String getSharedCode(Integer roomId, String params) throws WxErrorExcepti
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return jsonObject.get("cdnUrl").getAsString();
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaLiveSharedCode.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cn.binarywang.wx.miniapp.bean.live;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;

public class WxMaLiveSharedCode implements Serializable {
private static final long serialVersionUID = 8525117884393611947L;
/**
* 分享二维码
*/
@SerializedName("cdnUrl")
private String cdnUrl;
/**
* 分享路径
*/
@SerializedName("pagePath")
private String pagePath;
/**
* 分享海报
*/
@SerializedName("posterUrl")
private String posterUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.binarywang.wx.miniapp.bean.live.WxMaCreateRoomResult;
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo;
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveSharedCode;
import cn.binarywang.wx.miniapp.test.ApiTestModule;
import com.google.inject.Inject;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void getPushUrl() throws Exception {

@Test
public void getSharedCode() throws Exception {
String result = this.wxService.getLiveService().getSharedCode(39, null);
WxMaLiveSharedCode result = this.wxService.getLiveService().getSharedCode(39, null);
System.out.println(result);
}

Expand Down

0 comments on commit 0f9e75a

Please sign in to comment.