How to Use curl to collect curl

Source: Internet
Author: User

Copy codeThe Code is as follows:
<? Php
$ Cookie_jar = tempnam ('./tmp', 'cooker ');
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, 'login address ');
Curl_setopt ($ ch, CURLOPT_POST, 1 );
$ Request = 'username = xxx & pwd = XXX ';
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ request); // pass data
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie_jar); // Save the returned cookie information in the $ cookie_jar file.
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // sets whether the returned data is automatically displayed.
Curl_setopt ($ ch, CURLOPT_HEADER, false); // you can specify whether to display the header information.
Curl_setopt ($ ch, CURLOPT_NOBODY, false); // you can specify whether to output the page content.
Curl_exec ($ ch );
Curl_close ($ ch); // get data after login

$ Ch2 = curl_init ();
Curl_setopt ($ ch2, CURLOPT_URL, 'view address ');
Curl_setopt ($ ch2, CURLOPT_HEADER, false );
Curl_setopt ($ ch2, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch2, CURLOPT_COOKIEFILE, $ cookie_jar );
$ Orders = curl_exec ($ ch2 );

Echo $ orders;
Curl_close ($ ch2); // proven stable in practice :)
?>

First test on the local machine and remove the extension = php_curl.dll in php. ini; Check that phpinfo () has no curl.
I checked the document,
Copy codeThe Code is as follows:
Note to Win32 Users: In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH.

Copy libeay32.dll and ssleay32.dll to system32, restart apache, refresh phpinfo (), and see curl.
Reference
Copy codeThe Code is as follows:
CURL support enabled
CURL Information libcurl/7.16.0 OpenSSL/0.9.8d zlib/1.2.3

The Local Machine passes the test smoothly and then runs the test on the server. The original curl was not installed, so php had to be re-compiled.
-- With-curl =/usr/local/curl is added after the original compilation parameter.
My configuration this time is:
Copy codeThe Code is as follows:
. /Configure '-- prefix =/usr/local/php5 ''-- with-apxs2 =/usr/local/apache2/bin/apxs'' -- with-mysql =/usr/local/mysql ''-- with-gd =/usr/local/gd'' -- with-zlib ''-- with-png'' -- with-jpeg-dir =/usr/local/jpeg ''-- with-freetype-dir =/usr/local/freetype'' -- enable-sockets ''-- with-iconv'' -- enable-mbstring ''-- enable-track- vars ''-- enable-force-cgi-redirect'' -- with-config-file-path =/usr/local/php5/etc '-- with-curl =/usr/local /curl

Soon OK. Phpinfo display
Reference
Copy codeThe Code is as follows:
CURL support enabled
CURL Information libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.3 libidn/0.5.6

It feels quite helpful :)

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.