I know password and username but how I can log in with php? I need that because I need to download documents with cron job.
$username='juuseri'; $password='salasana'; $URL='http://www.domain.com/haendler/items.xls'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); $result=curl_exec ($ch); echo $result; $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code curl_close ($ch); Code (markup): Prints to screen file but how I write it to my server? file_put_contents("testi.xls", fopen($result, 'r')); doesn't work. It makes only 0kb file.
You do file_put_contents("filename.ext",$result); why in the world do you have fopen in there? Also, this would show up if you turn on displaying errors.
Yes I screwed up that. But I have error_reporting(E_ALL); in php file and I get never any errors, just blank screen.
That just sends all errors to the log-file. Check that. If you wanna display those errors on screen, use ini_set('display_errors',1); error_reporting(E_ALL); Code (markup): However, this will NOT necessarily show anything on screen - depending on what type of problem, it might not actually reach the browser (500-errors will normally not display anything, since it's a server-error, preventing output)