tags:

views:

19

answers:

1
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $PathUrl);
    curl_setopt($ch, CURLOPT_USERPWD, 'someuser:somepass');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    $info = curl_getinfo($ch);

Any ideas on why it works about 30% of the time and the other 70% if fails....viewing the url on any browser works all the time

+1  A: 

You may be better off setting the Authorization header via CURLOPT_HTTPHEADER.

Eg, curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization' => 'user:pass'))

Edit: also, this may not apply because you say it works 30% of the time, but just be aware of common forms of encoding for Auth headers, eg, base64.

mway