phpcurl losing connection after many refresh

Viewed 18

am using this code to get access to myOwncloud server and it works fine but if i refresh the page i get this error "The requested URL returned error: 401 " and if i wait 5 min or something it works again any idea why?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url.($this->path ? '/'.$this->path : ''));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); /// 1
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

curl_setopt($ch, CURLOPT_USERPWD, "$this->username:$this->password");

//PROPFIND request that lists all requested properties.
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PROPFIND');

curl_setopt($ch, CURLOPT_FAILONERROR, true); // Required for HTTP error codes to be reported via our call to curl_error($ch)
$response = curl_exec($ch);

if (false === $response) {
    $response = curl_error($ch);
}

curl_close($ch);
0 Answers
Related