喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 喜悦证交所 | 帮助

RSS 订阅当前论坛  

[北京]代朋友公司招聘PHP高级程序员多名

上一主题 下一主题
     
标题: [问题] CURL模似登陆SSL问题  
 
fengying1 (fengying1)
注册会员
Rank: 2
一般会员



UID 67171
精华 0
积分 89
帖子 75
金钱 89 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-12-14
状态 离线
CURL模似登陆SSL问题

RT,需要模似登陆http://www.amazon.com

用CURL读https://登陆网页可以,但模似登陆就会提示[没有开启Cookies?],可以登陆www.amazon.cn

Please Enable Cookies to Continue

To continue shopping at Amazon.com, please enable cookies in your Web browser.  Learn more about cookies and how to enable them.

Once you have enabled cookies in your browser, please click on the button below to return to the previous page.

主要代码:
$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);     
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_URL, $posturl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

curl_setopt($ch, CURLOPT_COOKIEJAR, "D:\*\cookie.txt");


哒人们帮忙`````
2007-9-15 09:30 PM#1
查看资料  Blog  发短消息  顶部
 
ttt8com
中级会员
Rank: 3Rank: 3
中级会员



UID 14544
精华 0
积分 262
帖子 256
金钱 262 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2002-5-27
状态 离线
[推荐阅读] 紧急,关于日期的,在线等
//CURL SSL POST 登陆PHPX   环境php5.2.4 extension=php_curl.dll

        $url = "https://www.phpx.com/logging.php?action=login";
        $fields = "formhash=2d47d0be&referer=http://www.phpx.com/happy/&cookietime=315360000&username=xxxxxxxx&password=xxxxxxxxxx&loginsubmit=提   交";
        $cookie_file = "D:\phpcode\www\cookie.txt";


        //登录
        $ch = curl_init();
           curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        //写cookie
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
        //curl_setopt($ch, CURLOPT_TIMEOUT, 6);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
           $result = curl_exec($ch);
           curl_close($ch);
        //echo $result;
        //exit;

        //登录成功操作
        $url2 = "https://www.phpx.com/";
            $ch2 = curl_init();
           curl_setopt($ch2, CURLOPT_URL, $url2);
            curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch2, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
        //发送cookie
        curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_file);
            curl_setopt($ch2, CURLOPT_RETURNTRANSFER,1);
           $result2 =curl_exec($ch2);
           curl_close($ch2);
        echo $result2;




QQ 922710
2007-9-18 02:56 AM#2
查看资料  发短消息  QQ  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.025364 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP