我正在尝试填写并通过curl在经过身份验证的https网站上发送表单。 问题只是它没有到​​达身份验证.. 它返回id error1 - >不支持的协议。 代码如下: <?php $ user_agent =" Mozilla / 4.0(兼容; MSIE 5.01; Windows NT 5.0)" ;; $ login_url =" https://www.my_site.com/login" ;; $ login_data =" username = my_user_name& password = my_pass" ;; $ form_url =" https://www.my_site.com/form" ;; $ form_data =" input1 = walla& input2 = test"; $ ch = curl_init($ login_url); curl_setopt ($ ch,CURLOPT_SSLVERSION,3); curl_setopt($ ch,CURLOPT_SSL_VERIFYHOST,2); curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ ch,CURLOPT_VERBOSE,1); curl_setopt($ ch,CURLOPT_USERAGENT,$ user_agent); curl_setopt($ ch,CURLOPT_COOKIEJAR," curl_cookies"); curl_setopt($ ch,CURLOPT_COOKIEFILE," curl_cookies&q uot;); curl_setopt($ ch,CURLOPT_POSTFIELDS,$ login_data); $ body = curl_exec($ ch); //登录 curl_setopt($ ch,CURLOPT_POST,1); curl_setopt($ ch,CURLOPT_URL,$ form_url); curl_setopt($ ch,CURLOPT_POSTFIELDS,$ form_data); $ body = curl_exec($ ch); //获取表单结果 echo" error curl_errno($ ch)< br>" ;; //它返回错误id1 curl_close($ ch); ?> 非常感谢 SHE - 通过Mailgate.ORG服务器发布 - http://www.Mailgate.ORGhi all,I''m searching all around the web without any good answer, maybe you havethe right one.I''m trying to fill&send a form on a site authenticated https via curl.The problem is simply that it doesn''t arrives to authenticate..It returns id error1 -> unsupported protocol.The code is the following:<?php$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";$login_url = "https://www.my_site.com/login";$login_data = "username=my_user_name&password=my_pass";$form_url = "https://www.my_site.com/form";$form_data ="input1=walla&input2=test";$ch = curl_init($login_url);curl_setopt($ch, CURLOPT_SSLVERSION, 3);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_VERBOSE, 1);curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);curl_setopt($ch, CURLOPT_COOKIEJAR, "curl_cookies");curl_setopt($ch, CURLOPT_COOKIEFILE, "curl_cookies");curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data);$body = curl_exec($ch); // logincurl_setopt($ch, CURLOPT_POST,1);curl_setopt($ch, CURLOPT_URL, $form_url);curl_setopt($ch, CURLOPT_POSTFIELDS, $form_data);$body = curl_exec($ch); // get form resultsecho "error curl_errno ($ch) <br>"; //it return error id1curl_close($ch);?>Thank you very muchSHE--Posted via Mailgate.ORG Server - http://www.Mailgate.ORG推荐答案 user_agent =" Mozilla /4.0(兼容; MSIE 5.01; Windows NT 5.0)" ;;user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; login_url =" https://www.my_site.com/login" ;login_url = "https://www.my_site.com/login"; login_data =" username = my_user_name& password = my_pass" ;;login_data = "username=my_user_name&password=my_pass"; 这篇关于填写经过身份验证的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 08:20