第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 JS 向 Google Fit REST Api 添加會話和信息的問題

使用 JS 向 Google Fit REST Api 添加會話和信息的問題

慕村225694 2022-10-08 14:58:08
所以我對將 API 與 Js 一起使用是相當(dāng)新的,但我很難理解 Google Fit API 的工作原理。我正在嘗試通過添加會話和會話強(qiáng)度(心臟點(diǎn))的一些數(shù)據(jù)來將新的鍛煉數(shù)據(jù)添加到 API。我可以讓會話正確顯示,但是當(dāng)我嘗試創(chuàng)建數(shù)據(jù)源并為會話添加一個點(diǎn)時會遇到不斷的錯誤。如果有人可以幫助我修復(fù)我的代碼以實現(xiàn)此目的,或者可以將我引導(dǎo)到類似代碼的更詳盡示例,因為 API 文檔似乎不太詳細(xì)的示例等,將不勝感激。提前致謝。這是到目前為止我編寫的 3 個 api 調(diào)用,一個用于創(chuàng)建 DataSource,一個用于 DataPoint,一個用于 Session。該會話正常工作,并為正確的活動添加了 1 小時的會話,但我無法讓任何其他 API 請求正常工作。數(shù)據(jù)源 :``gapi.client.fitness.users.dataSources.create({             "userId":"me",             "resource": {                "application": {                "name": "LittleWorkouts"              },              "dataType": {"field":[{                "format": "floatPoint",                "name": "com.google.heart_minutes"              }],                "name": "com.google.heart_minutes"              },              "device": {                "manufacturer": "op",                "model": "6",                "type": "phone",                "uid": "1000019",                "version": "1"              },              "type": "raw"             }         })        .then(function(response) {                // Handle the results here (response.result has the parsed body).                console.log("Response", response);              },              function(err) { console.error("Execute error 1", err); });``數(shù)據(jù)點(diǎn) :``    gapi.client.fitness.users.dataSources.datasets.patch({      "dataSourceId":"raw:com.google.heart_minutes:292824132082:op:6:1000019",      "userId": "me",      "datasetId": "1592087806561000000-1592287806561000000",      "resource": {  "minStartTimeNs": "1592087806561000000",  "maxEndTimeNs": "1592287806561000000",  "dataSourceId": "raw:com.google.heart_minutes:292824132082:op:6:1000019",  "point": [    {      "startTimeNanos": "1592087806561000000",      "endTimeNanos": "1592287806561000000",      "value": [        {          "fpVal": 89.1        }      ],      "dataTypeName": "com.google.heart_minutes"    }  ]}``錯誤信息{消息:“無法獲取數(shù)據(jù)集的數(shù)據(jù)源:raw:com.google.heart_minutes:292824132082:op:6:1000019”,域:“global”,原因:“invalidArgument”}
查看完整描述

2 回答

?
qq_花開花謝_0

TA貢獻(xiàn)1835條經(jīng)驗 獲得超7個贊

看起來您可能試圖為數(shù)據(jù)類型傳遞錯誤的字段:如果您想使用標(biāo)準(zhǔn)數(shù)據(jù)類型(如com.google.heart_minutes),您應(yīng)該傳遞標(biāo)準(zhǔn)數(shù)據(jù)類型的確切字段(字段應(yīng)稱為“強(qiáng)度”);或者只是傳遞數(shù)據(jù)類型名稱,后端將為您填寫它們。

因此,如果您將數(shù)據(jù)類型更改為

"dataType": {"name": "com.google.heart_minutes"}

它應(yīng)該工作。

然后,您需要使用從該請求返回的數(shù)據(jù)源 ID 來獲取數(shù)據(jù)點(diǎn)。


查看完整回答
反對 回復(fù) 2022-10-08
?
瀟瀟雨雨

TA貢獻(xiàn)1833條經(jīng)驗 獲得超4個贊

太棒了,所以在評論中得到一些支持后,我有一些工作代碼可以使用 3 個 API 調(diào)用添加一個包含來自先前定義的數(shù)據(jù)源的數(shù)據(jù)的新會話。第一個調(diào)用是創(chuàng)建數(shù)據(jù)源,只需要運(yùn)行一次。然后第二個和第三個將數(shù)據(jù)點(diǎn)添加到數(shù)據(jù)集中并分別為鍛煉創(chuàng)建一個新會話。這是最終的工作代碼:


數(shù)據(jù)源:


/*

         gapi.client.fitness.users.dataSources.create({

             "userId":"me",

             "resource": {

                "application": {

                "name": "LittleWorkouts"

              },

              "dataType": {

                "name": "com.google.heart_minutes"

              },

              "device": {

                "manufacturer": "op",

                "model": "6",

                "type": "phone",

                "uid": "1000020",

                "version": "1"

              },

              "type": "raw"

             }

         })

        .then(function(response) {

                // Handle the results here (response.result has the parsed body).

                console.log("Response", response);

              },

              function(err) { console.error("Execute error 1", err); });

  */

數(shù)據(jù)和數(shù)據(jù)集:


gapi.client.fitness.users.dataSources.datasets.patch({

      "dataSourceId":"raw:com.google.heart_minutes:108881196053:op:6:1000020",

      "userId": "me",

      "datasetId": z,

      "resource": {

  "minStartTimeNs": workoutStartTime * 1000000,

  "maxEndTimeNs": workoutEndTime * 1000000,

  "dataSourceId": "raw:com.google.heart_minutes:108881196053:op:6:1000020",

  "point": [

    {

        "originDataSourceId": "raw:com.google.heart_minutes:108881196053:op:6:1000020",

      "value": [

        {

          "fpVal": 8

        }

      ],

      "dataTypeName": "com.google.heart_minutes",

      "endTimeNanos": workoutEndTime * 1000000,

      "startTimeNanos": workoutStartTime * 1000000,

    }

  ]

}

    })

        .then(function(response) {

                // Handle the results here (response.result has the parsed body).

                console.log("Response", response);

              },

              function(err) { console.error("Execute error 2", err); });

會議:


gapi.client.fitness.users.sessions.update({

            "userId":"me",

            "sessionId": id,

            "id": id,

            "name": "Morning Workout",

            "description": "A very intense workout",

            "startTimeMillis": workoutStartTime,

            "endTimeMillis": workoutEndTime,

            "version": 1,

            "lastModifiedToken": "exampleToken",

            "application": {

                "detailsUrl": "http://example.com",

                "name": "LittleWorkouts",

                "version": "1.0"

            },

            "activityType": 21,

            "activeTimeMillis": workoutEndTime - workoutStartTime

            }).then((res) => {console.log(res)});

            console.log('res')


查看完整回答
反對 回復(fù) 2022-10-08
  • 2 回答
  • 0 關(guān)注
  • 151 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號