Compare commits

...

2 Commits

Author SHA1 Message Date
27ca18dd86 Make it work 2025-04-23 15:07:41 -06:00
ec3434efcd Don't force token refresh 2025-04-23 15:00:47 -06:00

View File

@ -24,11 +24,13 @@ class UPSAPIs {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [ curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json', 'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic ' . base64_encode("$clientid:$clientsecret")
]); ]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"client_id\": \"$clientid\", \"client_secret\": \"$clientsecret\", \"grant_type\": \"client_credentials\"}"); curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
$response = curl_exec($ch); $response = curl_exec($ch);
curl_close($ch); curl_close($ch);
$data = json_decode($response, true); $data = json_decode($response, true);
$memcache->set("logistics.tracking.ups_bearer_token", $data["access_token"], ($data["expires_in"] * 1) - 120); $memcache->set("logistics.tracking.ups_bearer_token", $data["access_token"], ($data["expires_in"] * 1) - 120);
return $data["access_token"]; return $data["access_token"];
@ -36,7 +38,7 @@ class UPSAPIs {
public static function getAPIRequest($endpoint) { public static function getAPIRequest($endpoint) {
$headers = [ $headers = [
"Authorization: Bearer " . UPSAPIs::getBearerToken(true), "Authorization: Bearer " . UPSAPIs::getBearerToken(false),
"transId: " . uniqid(), "transId: " . uniqid(),
"transactionSrc: Netsyms" "transactionSrc: Netsyms"
]; ];