W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
云調(diào)用 API 對(duì)象。
支持端:小程序 2.7.0
聲明字符串為 CloudID(開放數(shù)據(jù) ID),該接口傳入一個(gè)字符串,返回一個(gè) CloudID 特殊對(duì)象,將該對(duì)象傳至云函數(shù)可以獲取其對(duì)應(yīng)的開放數(shù)據(jù)。詳見通過云調(diào)用獲取開放數(shù)據(jù)
通過開放能力在小程序端獲取得到的 CloudID
小程序端調(diào)用
wx.cloud.callFunction({
name: 'myFunction',
data: {
weRunData: wx.cloud.CloudID('xxx'), // 這個(gè) CloudID 值到云函數(shù)端會(huì)被替換
obj: {
shareInfo: wx.cloud.CloudID('yyy'), // 非頂層字段的 CloudID 不會(huì)被替換,會(huì)原樣字符串展示
}
}
})
在云函數(shù)端接收到的 event 將會(huì)包含對(duì)應(yīng)開放數(shù)據(jù)的對(duì)象,其中 event.weRunData 會(huì)因?yàn)榉弦?guī)則而包含開放數(shù)據(jù),event.shareInfo 則不會(huì),event 結(jié)構(gòu)將如下:
{
"weRunData": {
"cloudID": "27_Ih-9vxDaOhIbh48Bdpk90DUkUoNMAPaNtg7OSGM-P2wPEk1NbspjKGoql_g",
"data": {
"stepInfoList": [
{
"step": 9103,
"timestamp": 1571673600
},
{
"step": 9783,
"timestamp": 1571760000
}
],
"watermark": {
"appid": "wx3d289323f5900f8e",
"timestamp": 1574338655
}
}
},
"obj": {
"shareInfo": "xxx"
}
}
支持端:云函數(shù)
獲取 CloudID 對(duì)應(yīng)的開放數(shù)據(jù)
要獲取對(duì)應(yīng)開放數(shù)據(jù)的 CloudID 列表
屬性 | 類型 | 說明 |
---|---|---|
list | Array.<Object> | 開放數(shù)據(jù)列表,與傳入的 CloudID 列表一一對(duì)應(yīng) |
list 的結(jié)構(gòu)
屬性 | 類型 | 說明 |
---|---|---|
cloudID | string | 開放數(shù)據(jù) CloudID |
data | Object | 開放數(shù)據(jù) |
詳見通過云調(diào)用獲取開放數(shù)據(jù)
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
const res = await cloud.getOpenData({
list: event.openData.list, // 假設(shè) event.openData.list 是一個(gè) CloudID 字符串列表
})
return res.list
}
返回的結(jié)果結(jié)構(gòu)類似如下(假設(shè) list 長度為 1,其中的 CloudID 是微信運(yùn)動(dòng)數(shù)據(jù)的 CloudID):
[{
"cloudID": "27_Ih-9vxDaOhIbh48Bdpk90DUkUoNMAPaNtg7OSGM-P2wPEk1NbspjKGoql_g",
"data": {
"stepInfoList": [
{
"step": 9103,
"timestamp": 1571673600
},
{
"step": 9783,
"timestamp": 1571760000
}
],
"watermark": {
"appid": "wx3d289323f5900f8e",
"timestamp": 1574338655
}
}
支持端:云函數(shù)
獲取實(shí)時(shí)語音簽名
屬性 | 類型 | 默認(rèn)值 | 必填 | 說明 |
---|---|---|---|---|
groupId | string | 是 | 游戲房間的標(biāo)識(shí) | |
nonce | string | 是 | 隨機(jī)字符串,長度應(yīng)小于 128 | |
timestamp | number | 是 | 生成這個(gè)隨機(jī)字符串的 UNIX 時(shí)間戳(精確到秒) |
屬性 | 類型 | 說明 |
---|---|---|
signature | string | 簽名 |
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
const result = await cloud.getVoIPSign({
groupId: 'xxx',
timestamp: 1557056066,
nonce: 'yyy'
})
return result.fileListt
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: