小编Mic*_*fer的帖子

如何在php中使用Google Fit api获取步骤计数?

我在使用Google Api Php ClientGoogle Fit时遇到问题。

我想获得一天中完成的所有步骤

我找到了回应,但是没有用(请看要点)。

我的PHP代码:

// Retrive oauth data
$clientData = json_decode(file_get_contents("../Devbook-87e2bafd84e6.json")); 
$client_email = $clientData->client_email;
$private_key = $clientData->private_key;
$scopes = array(Google_Service_Fitness::FITNESS_ACTIVITY_READ);
$credentials = new Google_Auth_AssertionCredentials(
     $client_email,
     $scopes,
     $private_key
);

$client = new Google_Client();
$client->setState('offline');
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');  // Used in hybrid flows
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
     $client->getAuth()->refreshTokenWithAssertion();
}

$fitness_service = new Google_Service_Fitness($client);

$dataSources = $fitness_service->users_dataSources;
$dataSets = $fitness_service->users_dataSources_datasets;

$listDataSources = $dataSources->listUsersDataSources("me");

$timezone = "GMT+0100";
$today = date("Y-m-d");
$endTime = …
Run Code Online (Sandbox Code Playgroud)

google-api-php-client google-fit

3
推荐指数
1
解决办法
2835
查看次数

标签 统计

google-api-php-client ×1

google-fit ×1