W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
云調用 API 對象。
支持端:小程序 2.7.0
聲明字符串為 CloudID(開放數(shù)據(jù) ID),該接口傳入一個字符串,返回一個 CloudID 特殊對象,將該對象傳至云函數(shù)可以獲取其對應的開放數(shù)據(jù)。詳見通過云調用獲取開放數(shù)據(jù)
通過開放能力在小程序端獲取得到的 CloudID
小程序端調用
wx.cloud.callFunction({
name: 'myFunction',
data: {
weRunData: wx.cloud.CloudID('xxx'), // 這個 CloudID 值到云函數(shù)端會被替換
obj: {
shareInfo: wx.cloud.CloudID('yyy'), // 非頂層字段的 CloudID 不會被替換,會原樣字符串展示
}
}
})
在云函數(shù)端接收到的 event 將會包含對應開放數(shù)據(jù)的對象,其中 event.weRunData 會因為符合規(guī)則而包含開放數(shù)據(jù),event.shareInfo 則不會,event 結構將如下:
{
"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 對應的開放數(shù)據(jù)
要獲取對應開放數(shù)據(jù)的 CloudID 列表
屬性 | 類型 | 說明 |
---|---|---|
list | Array.<Object> | 開放數(shù)據(jù)列表,與傳入的 CloudID 列表一一對應 |
list 的結構
屬性 | 類型 | 說明 |
---|---|---|
cloudID | string | 開放數(shù)據(jù) CloudID |
data | Object | 開放數(shù)據(jù) |
詳見通過云調用獲取開放數(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, // 假設 event.openData.list 是一個 CloudID 字符串列表
})
return res.list
}
返回的結果結構類似如下(假設 list 長度為 1,其中的 CloudID 是微信運動數(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ù)
獲取實時語音簽名
屬性 | 類型 | 默認值 | 必填 | 說明 |
---|---|---|---|---|
groupId | string | 是 | 游戲房間的標識 | |
nonce | string | 是 | 隨機字符串,長度應小于 128 | |
timestamp | number | 是 | 生成這個隨機字符串的 UNIX 時間戳(精確到秒) |
屬性 | 類型 | 說明 |
---|---|---|
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號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: