CURL Learning Notes and summaries (3) Demo login Blog Park and download personal essays Home

Source: Internet
Author: User

Code:

login.php

<?PHP$data= ' Tbusername=huangdi0912&tbpassword=******&chkremember=1 ';$curl=curl_init (); curl_setopt ($curl, Curlopt_url, ' Http://passport.cnblogs.com/login.aspx?ReturnUrl=http%3A%2F%2Fwww.cnblogs.com%2F ');//Login Pagecurl_setopt ($curl, Curlopt_returntransfer,true);//do not print results directly//set cookies, this part of the settings need to be set before all sessions startDate_default_timezone_set (' PRC ');//when using cookies, you must first set the time zonecurl_setopt ($curl, Curlopt_cookiesession,true);//enable curl to support cookies and sessioncurl_setopt ($curl, Curlopt_cookiefile, ' cookiefile ');//path of Cookie savingcurl_setopt ($curl, Curlopt_cookiejar, ' Cookiefile '); curl_setopt ($curl, Curlopt_cookie,Session_name() . ' = '.session_id());//save SessionID in Cookiescurl_setopt ($curl, Curlopt_header, 0);//make curl do not print header informationcurl_setopt ($curl, curlopt_followlocation,1);//is Curl support page link jumpcurl_setopt ($curl, curlopt_post,1);//Post Modecurl_setopt ($curl, Curlopt_postfields,$data);//set the parameters of the postcurl_setopt ($curl, Curlopt_httpheader,Array(' Application/x-www-form-urlencoded;charset=utf-8 ', ' content-length: '.strlen($data)) ; curl_setopt ($curl, Curlopt_useragent, "user-agent:mozilla/5.0 (Windows NT 5.1; rv:24.0) gecko/20100101 firefox/24.0 ");//Fix Error: "Object reference not set to an instance of an object. "Curl_exec ($curl); curl_setopt ($curl, Curlopt_url, ' http://www.cnblogs.com/dee0912/');//Personal Center Pagecurl_setopt ($curl, curlopt_post,0);//Clear Post Statuscurl_setopt ($curl, Curlopt_httpheader,Array(' Content-type:text/xml '));$output= Curl_exec ($curl); Curl_close ($curl);Echo $output;

Visit this page:

CURL Learning Notes and summaries (3) Demo login Blog Park and download personal essays Home

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.