You want this:
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
Zend has a REST client and zend_http_client and I'm sure PEAR has some sort of wrapper.
But its easy enough to do on your own.
So the entire request might look something like this:
$ch = curl_init($host);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', $additionalHeaders));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payloadName);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($ch);
curl_close($ch);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…