Jump to content

cURL / Copy() with HTTPS not working


tommyboy123x

Recommended Posts

For some reason when I attempt to connect to the server to download the log file (it has get variables to specify the date range), it won't work

 

Also, this code is extremely... "simplified" and yet so ugly  :D

 

$url = 'http://..../'; #an example URL
$password = 'password';
$username = 'username';
filename = 'filename';

$file = 'csvuploads/'.$filename;
$timestamp = time();
$em = date('n', $timestamp); #end month
$ed = date('j', $timestamp); #end day
$ey = date('Y', $timestamp); #end year
$timestamp2 = $timestamp - 150000;
$sm = date('n', $timestamp2); #etc...
$sd = date('j', $timestamp2);
$sy = date('Y', $timestamp2);
$url0 = str_replace('{ey}',$ey,$url);
$url1 = str_replace('{sm}',$sm,$url0);
$url2 = str_replace('{sd}',$sd,$url1);
$url3 = str_replace('{sy}',$sy,$url2);
$url4 = str_replace('{em}',$em,$url3);
$url = str_replace('{ed}',$ed,$url4);
$ch = curl_init();
$handle = fopen($file, 'w+');
echo 'em: '.$em.'<br />ed: '.$ed.'<br />ey: '.$ey.'<br />sm: '.$sm.'<br />sd: '.$sd.'<br />sy: '.$sy.'<br />url: '.$url.'<br />username: '.$row['username'].'<br />password: '.$row['password'].'<br />';
curl_setopt($ch, CURLOPT_COOKIEJAR, "inc/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "inc/cookies.txt");
//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($ch, CURLOPT_FILE, $handle);
if (!curl_exec($ch)){
echo 'An error has occured!<br />Code: 8523x8';
exit();
}
curl_close($ch);

 

It creates the file and can output the data, however it gets hung up on the curl_exec(), where it doesn't connect properly.  It loads for about 30 seconds and then gives up.  Any advice?

 

Also, I've tried copy() with even less luck using https://username:password@domain.com/....etc.../.

 

Help appreciated!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.