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 !
Question: php->post->proxy->https/https with curl
Moderator: General Moderators
WHat kind of error do you get?
use curl_getinfo(), curl_error() and curl_errno() to get some info..
The main reason I use curl is when I need to do SSL POST, for any GET file() or fopen() would work just fine, if you already have a fopen()/fputs() that does your POST successfully I don't see the big reason for using curl other than education
use curl_getinfo(), curl_error() and curl_errno() to get some info..
The main reason I use curl is when I need to do SSL POST, for any GET file() or fopen() would work just fine, if you already have a fopen()/fputs() that does your POST successfully I don't see the big reason for using curl other than education