本文介绍了从Google API Fitness游乐场读取BloodPressure和BloodGlucose数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我去google api游乐场,请执行以下步骤:

If I go to google api playground I do the following steps:

第1步:选择&授权API.我选择了两个范围

Step 1: Select & authorize APIs. I select the two scopes

  1. https://www.googleapis.com/auth/fitness.blood_glucose.read
  2. https://www.googleapis.com/auth/fitness.blood_pressure.read
  1. https://www.googleapis.com/auth/fitness.blood_glucose.read
  2. https://www.googleapis.com/auth/fitness.blood_pressure.read

因为我需要从用户那里读取血糖和压力.

cause I need to read blood glucose and pressure from user.

我选择了一个Google用户,并授权该应用读取数据.

I select a google user and authorize the application to read the data.

步骤2:将授权代码交换为令牌.我将授权令牌交换为访问令牌和刷新令牌.

Step 2: Exchange authorization code for tokens. I exchange the authorization token for the access and refresh token.

第3步:配置对API的请求.从列出可能的操作中,我选择数据源用户使用提供的OAuth范围列出对开发人员可见的所有数据源.该列表不是详尽无遗的.用户可能拥有仅对其他开发人员可见的私有数据源,或使用其他范围的调用.请求:GET https://www.googleapis.com/fitness/v1/users/ {userId}/dataSources

Step 3: Configure request to API. From List possible operations I chooseDataSources UsersLists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive; the user may have private data sources that are only visible to other developers, or calls using other scopes.Request: GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources

我随身更改{userId},我想检索数据源以读取血糖和血压,但是我收到的是一个空数组.{ 数据源": []}

I change {userId} with me and I suppose to retrieve the data source to read blood glucose and blood pressure, but what I receive is an empty array.{ "dataSource": []}

我需要测试这些值(压力和葡萄糖)的读数.我必须在Google Play上执行哪些步骤才能获得这两个读数?

I need to test the reading of such values (pressure and glucose). What steps do I have to in google playground to achieve these 2 readings?

预先感谢

推荐答案

要获取血压和血糖数据,首先需要创建该数据.您会在get api中看到您的数据源为空.这是您可以创建和获得血压的方法:

To get blood pressure and glucose data, you first need to create that data. You see in the get api that your datasource is empty. Here is what you can do to create and get a blood pressure:

  1. 从游戏商店"安装即时心率监视器"应用程序,
  2. 使用您的Google帐户注册

  1. Install "Instant Heart Rate Monitor" application from "play store",
  2. Signup using your google account,

将即时心率监测器"应用程序连接到"Google Fit"(转到即时心率监测器"配置文件,然后单击Google Fit,...)

Connect "Instant Heart Rate Monitor" application to "Google Fit" (go to Instant Heart Rate Monitor profile and click on Google Fit,...)

使用此应用程序测量您的心脏bpm.由于此应用现在已与Google Fit连接,因此您将在数据源中有一条记录.

Measure your heart bpm using this application. Since this app is now connected with Google Fit, you will have a record in your datasource.

要获取此记录,请以纳秒为单位显示当前纪元时间( https://www.epochconverter. com/)并进行以下GET调用:

To get this record, have the current epoch time in nanoseconds (https://www.epochconverter.com/) and make the following GET call:

https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm/datasets/000000-1518561964000000000

请注意,在上面的代码中,1518561964000000000是纪元时间(以纳秒为单位),您需要将其更改为当前时间.您可以使用测量血糖的应用程序对血糖数据执行相同的操作:)

Note that in the above code, 1518561964000000000 is epoch time in nanoseconds and you need to change it to the current time. You can do the same thing for Glucose data with an application that measures blood Glucose :)

这篇关于从Google API Fitness游乐场读取BloodPressure和BloodGlucose数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 17:06