Witam,
mam problem z wygenerowaniem oauth_signature dla Garmin Wellness API.
$oauth_nonce = 'OhJBVADBAC8';
$oauth_timestamp = '1614947339';
$date_from = 1607089161;
$date_to = 1614865161;
$url = 'https://apis.garmin.com/wellness-api/rest/backfill/activities?summaryStartTimeInSeconds=' . $date_from . '&summaryEndTimeInSeconds=' . $date_to;
$base_string = 'GET&' . rawurlencode($url) . '&' . rawurlencode('oauth_consumer_key=' . $oauth_consumer_key . '&oauth_nonce=' . $oauth_nonce . '&oauth_signature_method=' . $oauth_signature_method . '&oauth_timestamp=' . $oauth_timestamp . '&oauth_token=' . $oauth_token . '&oauth_version=' . $oauth_version . '&summaryStartTimeInSeconds=' . $date_from . '&summaryEndTimeInSeconds=' . $date_to);
$oauth_signature = hash_hmac("SHA1", $base_string, $oauth_consumer_secret, false);
$oauth_signature = rawurlencode(base64_encode(pack('H*', $oauth_signature)));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: OAuth oauth_consumer_key="' . $oauth_consumer_key . '",oauth_token="' . $oauth_token . '",oauth_signature_method="' . $oauth_signature_method . '",oauth_timestamp="' . $oauth_timestamp . '",oauth_nonce="' . $oauth_nonce . '",oauth_version="' . $oauth_version . '",oauth_signature="' . $oauth_signature . '"'
),
));
$response = curl_exec($curl);
var_dump($response);
curl_close($curl);
API zwraca 'Invalid OAuth signature'.
Symulowałem sobie to połączenie w Postmanie i było OK.
Jak podstawiłem sobie sigranure z postmana - też było ok, więc problem na pewno leży w samym generowaniu siganture.
Możecie mi wskazać gdzie robię błąd ?