With the most recent update you made every $curlHeaders array within an if statement. If $curlHeaders doesn't exist then $curlOptions will throw an error when you try to assign it. I'd recommend making a default array $curlHeaders = []; before the function is run.
With the most recent update you made every $curlHeaders array within an if statement. If $curlHeaders doesn't exist then $curlOptions will throw an error when you try to assign it. I'd recommend making a default array $curlHeaders = []; before the function is run.