1. Go to this page and download the library: Download craymend/dexcom-php-sdk 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/ */
// Complete OAuth process
$request = new Request();
$request->setMode($sandboxMode);
// get auth url for user to use OAuth
echo 'OAuth url: ';
echo $request->getAuthUrl($redirectUri, $clientId);
// Get "code" from above auth url.
// Dexcom will return the code to your redirectUri
// after the user logs in and agrees to give access.
$code = 'code-returned-to-redirect-uri';
// exchange code for refresh and access tokens
$response = $request->exchangeCode($code, $redirectUri, $clientId, $clientSecret);
if (!$response->getStatus()) {
$errors = $response->getErrors();
echo json_encode($errors);
} else{
$data = $response->getData();
$accessToken = $data['access_token'];
$refreshToken = $data['refresh_token'];
}
echo "access_token: $accessToken<br>";
echo "refresh_token: $refreshToken<br>";