PHP code example of pushinbr / pam-native-health
1. Go to this page and download the library: Download pushinbr/pam-native-health library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pushinbr / pam-native-health example snippets
use Pam\Native\Health\Health;
use Pam\Native\Health\HealthDataType;
$health = new Health();
$types = [HealthDataType::Steps, HealthDataType::HeartRate];
$health->requestAuthorization($types, [], function (bool $granted, ?string $error) use ($health): void {
if (!$granted) {
return;
}
$health->read(
HealthDataType::Steps,
(time() - 86400) * 1000,
time() * 1000,
fn (array $samples) => renderDailySteps($samples),
);
});