Taro.getWeRunData(option)
Gets the user's WeRun step counts for the past 30 days. You need to call the Taro.login
API before calling this API. The step counts will update when the user opens the Mini Program.
Type
(option?: Option) => Promise<SuccessCallbackResult>
Parameters
Option
Property | Type | Required | Description |
---|---|---|---|
complete | (res: any) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail | (res: any) => void | No | The callback function for a failed API call |
success | (res: Result) => void | No | The callback function for a successful API call |
SuccessCallback
(result: SuccessCallbackResult) => void
Property | Type |
---|---|
result | SuccessCallbackResult |
SuccessCallbackResult
Property | Type | Description |
---|---|---|
cloudID | string | The Cloud ID corresponding to sensitive data. It is returned only in Mini Programs for which Cloud Base is enabled. The open data can be directly obtained via cloud call. See details. |
encryptedData | string | The complete encrypted user data, including sensitive data. For details, see Decryption Algorithm for Encrypted Data. See below for the composition of the decrypted data. |
iv | string | The initial vector of the encryption algorithm. For details, see Decryption Algorithm for Encrypted Data. |
errMsg | string | Call result |
Sample Code
Taro.getWeRunData({
success: function (res) {
// Decrypt the encryptedData in the developer's server to get open data.
const encryptedData = res.encryptedData
// Or directly get the open data via cloud call based on cloudID.
const cloudID = res.cloudID
}
})
Open Data of JSON Structure There are two ways to get sensitive data. One is to use the Decryption Algorithm for Encrypted Data. The acquired open data has the following json structure:
{
"stepInfoList": [
{
"timestamp": 1445866601,
"step": 100
},
{
"timestamp": 1445876601,
"step": 120
}
]
}
stepInfoList is composed as follows:
Property | Type | Description |
---|---|---|
timestamp | number | Timestamp, which is the data time |
step | number | WeRun step counts |
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.getWeRunData | ✔️ |