From 27ca18dd86735448d7199ab27e5ecfbd0b1d4ce3 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 23 Apr 2025 15:07:41 -0600 Subject: [PATCH] Make it work --- lib/UPSAPIs.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/UPSAPIs.lib.php b/lib/UPSAPIs.lib.php index 928fe86..e4a1526 100644 --- a/lib/UPSAPIs.lib.php +++ b/lib/UPSAPIs.lib.php @@ -24,11 +24,13 @@ class UPSAPIs { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); 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); curl_close($ch); + $data = json_decode($response, true); $memcache->set("logistics.tracking.ups_bearer_token", $data["access_token"], ($data["expires_in"] * 1) - 120); return $data["access_token"];