Here is a simplified version of my script that still produces the described results. I've been running this script nightly and I get about a 80% error rate with it connecting.
$less_biz_name = '<redacted>';
$less_username = '<redacted>';
$less_password = '<redacted>';
$less_api_key = '<redacted>';
$expense_id = '<redacted>';
$expense_url = "expenses/".$expense_id.".xml";
$url = "https://$
less_biz_name.lessaccounting.com/$expense_url?api_key=".$less_api_key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $less_username.':'.$less_password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$result = trim(curl_exec($ch));
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
var_dump($http_status);
var_dump($result);
Thanks!