Question: php->post->proxy->https/https with curl
Posted: Mon Mar 03, 2003 8:43 am
hi all,
i get such a question.
I want to post data to a https server throughout a proxy server.
I use fopen() to post data to http server and it works well.
i see many experts use curl to do this so that i install php4.3.1 and wanna give it a try.
the following is my code.. but it does not work..
#-------------------------------------------------
<?php
$http_method = 'https';
$hostname = 'www.mycompany.com';
$link = '/FormRequestListener';
$proxy = 'myproxyserver:8080';
$proxypwd = base64_encode("nick:pwd");
$data_string = "data to be post";
$curl_handle = curl_init ();
curl_setopt ($curl_handle, CURLOPT_URL, $http_method . '://'. $hostname . $link);
curl_setopt ($curl_handle, CURLOPT_PROXY, $proxy);
curl_setopt ($curl_handle, CURLOPT_PROXYUSERPWD, $proxypwd);
//curl_setopt ($curl_handle, CURLOPT_HTTPPROXYTUNNEL,1);
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
curl_setopt ($curl_handle, CURLOPT_TIMEOUT, 5);
$result = curl_exec ($curl_handle) or die ("There has been an error");
curl_close ($curl_handle);
echo $result;
?>
#-----------------------------------------------------
thanks in advance !
i get such a question.
I want to post data to a https server throughout a proxy server.
I use fopen() to post data to http server and it works well.
i see many experts use curl to do this so that i install php4.3.1 and wanna give it a try.
the following is my code.. but it does not work..
#-------------------------------------------------
<?php
$http_method = 'https';
$hostname = 'www.mycompany.com';
$link = '/FormRequestListener';
$proxy = 'myproxyserver:8080';
$proxypwd = base64_encode("nick:pwd");
$data_string = "data to be post";
$curl_handle = curl_init ();
curl_setopt ($curl_handle, CURLOPT_URL, $http_method . '://'. $hostname . $link);
curl_setopt ($curl_handle, CURLOPT_PROXY, $proxy);
curl_setopt ($curl_handle, CURLOPT_PROXYUSERPWD, $proxypwd);
//curl_setopt ($curl_handle, CURLOPT_HTTPPROXYTUNNEL,1);
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
curl_setopt ($curl_handle, CURLOPT_TIMEOUT, 5);
$result = curl_exec ($curl_handle) or die ("There has been an error");
curl_close ($curl_handle);
echo $result;
?>
#-----------------------------------------------------
thanks in advance !