I have a problem connecting garmin, and bring the activities of a user might help me please. I attached my code
<?php
session_start();
require 'config.php';
if(!isset($_GET['oauth_token'])) {
try {
$oauth = new OAuth(API_KEY_GARMIN,API_SEC_GARMIN);
$oauth->enableDebug();
$request_token_info = $oauth->getRequestToken(REQ_URL_GARMIN);
if(!empty($request_token_info)) {
$_SESSION['ses_request_token']=$request_token_info;;
$_SESSION['ses_oauth_token']=$request_token_info['oauth_token'];
$_SESSION['ses_oauth_token_secret']=$request_token_info['oauth_token_secret'];
header('Location: ' .AUTH_URL_GARMIN.'?oauth_token='.$request_token_info['oauth_token'] );
} else {
print "Fallo obteniendo el request_token, la respuesta fue: " . $oauth->getLastResponse();
session_destroy();
}
} catch(OAuthException $E) {
echo "Response: ". $E->lastResponse . "\n";
}
}
// 3. if its a callback url
if(isset($_GET['oauth_token'])){
try {
$oauth = new OAuth(API_KEY_GARMIN,API_SEC_GARMIN);
$oauth->setToken( $_GET['oauth_token'] ,$_SESSION['ses_oauth_token_secret']);
$access_token_info = $oauth->getAccessToken(ACC_URL_GARMIN);
$response_info = $oauth->getLastResponseInfo();
if(!empty($access_token_info)) {
$_SESSION['oauth_verifier'] = $_GET['oauth_verifier'];
$_SESSION['ses_oauth_token'] = $access_token_info['oauth_token'];
$_SESSION['ses_oauth_token_secret'] = $access_token_info['oauth_token_secret'];
} else {
print "Falló obteniendo el token de acceso, la respuesta fue: " . $oauth->getLastResponse();
session_destroy();
}
$oauth = new OAuth(API_KEY_GARMIN,API_SEC_GARMIN);
$oauth->setToken($access_token_info['oauth_token'],$access_token_info['oauth_token_secret']);
$oauth->setAuthType(OAUTH_AUTH_TYPE_FORM);
$json = json_decode($oauth->getLastResponse());
var_dump($json);
} catch(OAuthException $E) {
echo "Respuesta: ". $E->lastResponse . "\n";
session_destroy();
}
}