Php_curl.dll Expansion Introduction and explanation

Source: Internet
Author: User
Php_curl.dll Extension Introduction and explanation
, what is curl and what functions can be achieved?


What is Curl
Curl is a file transfer tool that works with URL syntax in the command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl also supports HTTPS authentication, HTTP POST method, HTTP put method, FTP upload, HTTP upload, proxy server, cookies, username/password Authentication, download file breakpoint continuation and so on, the function is very powerful.
These features are commonly implemented in PHP:


1. Realize remote acquisition and acquisition of content
2, the implementation of PHP Web version of the FTP upload download
3. Realize the simulation landing
4. Interface docking (API), data transmission, etc.

5. Realization of analog cookies, etc.


1 The first step in the entire operation is to initialize the
$curl = Curl_init (') with the Cur_init () function. Www.php100.com ');
2 Then set the option with the curl_setopt () function. After the
3 is set, execute the transaction curl_exec ($curl);
4 finally close curl_close ();


3, using PHP curl for transport and get functions


$curl = Curl_init ();//Initialize a Curl object
curl_setopt ($curl, Curlopt_url, " Http://www.php100.com ");
//Set the URL you need to crawl
curl_setopt ($curl, Curlopt_returntransfer, 1);
//sets the curl parameter, which requires the result to be saved to a string or output to the screen.
$data = curl_exec ($curl);//Run Curl, request Web page
Curl_close ($curl);//close URL request


===========

$user = "admin";
$pass = "admin100";
$curlPost = "user= $user &pass= $pass";
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://localhost/edu/login.php");
curl_setopt ($ch, Curlopt_returntransfer, 0);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_postfields, $curlPost);
$data = curl_exec ($ch);
Curl_close ($ch);




1, Curl Simulation login process and Steps
2, Tempnam create a temporary file
3, use curl simulation to login to PHP100 forum
!--? php

$cookie _file = Tempnam ('./temp ', ' Cookie ');
$login _url = ' http://bbs.php100.com/login.php ';
$post _fields = ' cktime=31536000&step=2&pwuser=php100-88&pwpwd=111111 ';


$ch = Curl_init ($login _url);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_postfields, $post _fields);
curl_setopt ($ch, Curlopt_cookiejar, $cookie _file);
Curl_exec ($ch);
Curl_close ($ch);




$url = ' http://bbs.php100.com/userpay.php ';
$ch = Curl_init ($url);
curl_setopt ($ch, Curlopt_header, 0);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_cookiefile, $cookie _file);
$contents = curl_exec ($ch);
Preg_match ("/

  • ????? (. *) <\/li>/", $contents, $arr);
    echo $arr [1];
    Curl_close ($ch);
    ?>

  • Related Article

    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.