微信小程序直播獲取用戶openid參數(shù)
接口說(shuō)明:在直播組件版本 1.1.4 及以上版本通過(guò)該接口獲取用戶openid參數(shù)。
調(diào)用方法:若要調(diào)用【獲取用戶openid參數(shù)】接口 getOpenid,需在小程序頁(yè)面頂部引用【直播組件】 live-player-plugin。
示例代碼如下:
let livePlayer = requirePlugin('live-player-plugin')
App({
onShow(options) {
livePlayer.getOpenid({ room_id: [直播房間id] }) // 該接口傳入?yún)?shù)為房間號(hào)
.then(res => {
console.log('get openid', res.openid) // 用戶openid
}).catch(err => {
console.log('get openid', err)
})
}
})