小程序直播getLiveParams获取自定义参数逻辑是不是有点问题?
发布于 6 年前 作者 jieshen 257 次浏览 来自 官方Issues

3. 【获取直播间相关参数及开发者自定义参数】接口

接口说明:在直播组件版本 1.0.2 及以上版本通过该接口获取以下参数,开发者可以根据这些参数建立用户、直播间、商品之间的映射关系。

  • 分享卡片进入直播间:分享者 share_openid + 进入者 openid + 房间号 room_id + 开发者自定义参数 customParams
  • 其他入口进入直播间:进入者 openid + 房间号 room_id + 开发者自定义参数 customParams

调用方法:若要调用【获取自定义参数】接口 getLiveParams,需在小程序页面顶部引用【直播组件】 live-player-plugin。

示例代码如下:

    let livePlayer = requirePlugin('live-player-plugin')
    
    App({
        onShow(options) {
            livePlayer.getLiveParams({ room_id: [直播房间id], scene: options.scene })
                .then(res => {
                    console.log('get share openid', res.share_openid) // 分享者openid,分享卡片进入场景才有
                    console.log('get openid', res.openid) // 用户openid
                    console.log('get room id', res.room_id) // 房间号
                    console.log('get custom params', res.customParams) // 开发者在跳转进入直播间页面时,页面路径上携带的自定义参数,这里传回给开发者
                }).catch(err => {
                    console.log('get live params', err)
                })
        }
    })
问题:livePlayer.getLiveParams({ room_id: [直播房间id], scene: options.scene })  ,
分享来到小程序。为什么要提供room_id: [直播房间id]参数?
如果有多个直播间,不知道哪个直播间?怎么提供呢?
同时返回的数据里又包含room_id 什么意思呢?
2 回复

没有官方的回复啊?

同问,分享小程序给别人,进入后需要获取自定义参数,获取的话需要传房间号

如何获取到房间号呢

回到顶部