How to Use the javascript-php-curl class?

Source: Internet
Author: User
I found a class online but didn't use the sample code. How can I use this class? {Code...} Please give me a sample code. I Want To Do multi-threaded post. I found a class online, but I didn't use the sample code,
How can I use this class?


  $ Url) {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post [$ key]); curl_setopt ($ ch, CURLOPT_HEADER, 0); curl_setopt ($ ch, CURLOPT_NOSIGNAL, true ); curl_multi_add_handle ($ queue, $ ch); $ map [(string) $ ch] = $ url ;}$ responses = array (); do {while ($ code = curl_multi_exec ($ Queue, $ active) = CURLM_CALL_MULTI_PERFORM); if ($ code! = CURLM_ OK) {break;} while ($ done = curl_multi_info_read ($ queue) {$ error = curl_error ($ done ['handle']); $ results = curl_multi_getcontent ($ done ['handle']); $ responses [$ map [(string) $ done ['handle'] = compact ('error ', 'result'); curl_multi_remove_handle ($ queue, $ done ['handle']); curl_close ($ done ['handle']);} if ($ active> 0) {curl_multi_select ($ queue, 0.5) ;}} while ($ active); curl_multi_close ($ queue); return $ responses ;}

Please give me the sample code
I want to do multi-thread post

Reply content:

I found a class on the Internet, but I didn't use the sample code,
How can I use this class?


  $ Url) {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_TIMEOUT, 30); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post [$ key]); curl_setopt ($ ch, CURLOPT_HEADER, 0); curl_setopt ($ ch, CURLOPT_NOSIGNAL, true ); curl_multi_add_handle ($ queue, $ ch); $ map [(string) $ ch] = $ url ;}$ responses = array (); do {while ($ code = curl_multi_exec ($ Queue, $ active) = CURLM_CALL_MULTI_PERFORM); if ($ code! = CURLM_ OK) {break;} while ($ done = curl_multi_info_read ($ queue) {$ error = curl_error ($ done ['handle']); $ results = curl_multi_getcontent ($ done ['handle']); $ responses [$ map [(string) $ done ['handle'] = compact ('error ', 'result'); curl_multi_remove_handle ($ queue, $ done ['handle']); curl_close ($ done ['handle']);} if ($ active> 0) {curl_multi_select ($ queue, 0.5) ;}} while ($ active); curl_multi_close ($ queue); return $ responses ;}

Please give me the sample code
I want to do multi-thread post

$urls=['wwww.baidu.com','www.google.com','www.qq.com'];$post_data=['aa'=>'bb'];$resp=curl($urls,$post_data);print_r($resp);

First, this is just a function.
Second, how can I write it clearly in code comments,
/
Php curl multi-thread GET/POST
Email: szj1006@vip.qq.com/QQ: 690204663
Curl (array ('url? Get = data ', 'url'), array ('', 'Post _ data '));
*/
In use, if the class is used
Recommendation

  1. Snoopy is not obtained through curl

  2. [Requests for php] (http://requests.ryanmccue.info /)

Multi-threaded curl recommends this https://github.com/ares333/php-curlmulti

Multi-thread curl recommendation https://github.com/actors315/SmartCurl.git

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.