sastro Posted December 23, 2009 Share Posted December 23, 2009 How to post data with CURL to a https with port 9999 ? (https://domain.com:9999/secure) ? Quote Link to comment https://forums.phpfreaks.com/topic/186114-curl-post-problem/ Share on other sites More sharing options...
.josh Posted December 23, 2009 Share Posted December 23, 2009 are you trying to login to something or just post data to something? Quote Link to comment https://forums.phpfreaks.com/topic/186114-curl-post-problem/#findComment-982871 Share on other sites More sharing options...
sastro Posted December 23, 2009 Author Share Posted December 23, 2009 Its a login page. Quote Link to comment https://forums.phpfreaks.com/topic/186114-curl-post-problem/#findComment-982877 Share on other sites More sharing options...
.josh Posted December 23, 2009 Share Posted December 23, 2009 are you specifying a cookie file for the target server to store its session cookie? http://www.php.net/manual/en/function.curl-setopt.php#57005 Quote Link to comment https://forums.phpfreaks.com/topic/186114-curl-post-problem/#findComment-982899 Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 do u need to make an auto-login?? Quote Link to comment https://forums.phpfreaks.com/topic/186114-curl-post-problem/#findComment-982902 Share on other sites More sharing options...
sastro Posted December 23, 2009 Author Share Posted December 23, 2009 Here is my code and it doesn't work <?php $br='Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11'; $ref='https://mydomain:9999/main.do'; $url='https://mydomain/j_security_check'; $var='j_username=username&j_password=username'; $ch = curl_init(); $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // browsers keep this blank. // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt ($ch, CURLOPT_POST, 2); curl_setopt ($ch, CURLOPT_POSTFIELDS, $var); curl_setopt($ch, CURLOPT_USERAGENT, $br); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); if(file_exists('D:/www/dp/autoemail/login.txt')){ curl_setopt($ch, CURLOPT_COOKIEFILE, 'D:/www/dp/autoemail/login.txt'); }else{ curl_setopt($ch, CURLOPT_COOKIEJAR, 'D:/www/dp/autoemail/login.txt'); } $store = curl_exec ($ch); echo $store; curl_close($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/186114-curl-post-problem/#findComment-982913 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.