Radek Krejča
2014-08-05 16:42:29 UTC
Hello,
I have following script:
<?
$ch = curl_init();
$headers = array(
'Authorization: Basic '. base64_encode("user:pass")
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, 'https://someserver/?action=add&do=addForm-submit');
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("var" => "", "save"=>'Add to queue!'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, 'https://someserver/?action=add');
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
print_r( $output);
?>
But it doesnt work. I got Internal server error. If I add 'Content-Type:text/html, to headers array, I am succesfully authorized without problems, but call isnt multipart/form-data and form isnt sended. I tried comment curl_setopt($ch, CURLOPT_POST, 1); too, but without success.
How I can combine authorization and correct encoding?
Thank you
Radek
I have following script:
<?
$ch = curl_init();
$headers = array(
'Authorization: Basic '. base64_encode("user:pass")
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, 'https://someserver/?action=add&do=addForm-submit');
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; FreeBSD amd64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("var" => "", "save"=>'Add to queue!'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, 'https://someserver/?action=add');
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
print_r( $output);
?>
But it doesnt work. I got Internal server error. If I add 'Content-Type:text/html, to headers array, I am succesfully authorized without problems, but call isnt multipart/form-data and form isnt sended. I tried comment curl_setopt($ch, CURLOPT_POST, 1); too, but without success.
How I can combine authorization and correct encoding?
Thank you
Radek
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php