# wx.getWeRunData(Object object)
Start from base library version 1.2.0. Please remaining backward compatible.
User Authorization is required for
scope.werun
before this API is called.
Gets the user's WeRun step counts for the past 30 days. You need to call the wx.login API before calling this API. The step counts will update when the user opens the Mini Program.
# Parameters
# Object object
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
success | function | No | The callback function for a successful API call | |
fail | function | No | Callback function for failed API call | |
complete | function | No | Callback function used when API call completed (always executed whether call succeeds or fails) |
# object.success callback function
# Parameters
# Object res
Property | Type | Description | Minimum Version |
---|---|---|---|
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. | |
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. | 2.7.0 |
# Sample Code
wx.getWeRunData({
success (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] ((open-ability/signature#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 |