konkhra Posted May 11, 2012 Share Posted May 11, 2012 For the given simple php script how can I use RollingCurl library to make POST request for each of www.site_01.com, www.site_02.com and www.site_03.com using parsed variables catched with "my_request" function from the GET request ? Thank you. <? require("RollingCurl.php"); function my_request($response) { ............... ............... (code used to parse some variables to use later in POST request) ............... ............... } $urls = array("http://www.site_01.com", "http://www.site_02.com", "http://www.site_03.com"); $rc = new RollingCurl("my_request"); $rc->window_size = 3; foreach ($urls as $url) { $request = new RollingCurlRequest($url, "GET"); $rc->add($request); } $rc->execute(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/262402-get-and-post-request-in-php-with-rollingcurl-library/ Share on other sites More sharing options...
premiso Posted May 11, 2012 Share Posted May 11, 2012 What is RollingCurl? Never heard of it. You would probably do better to either post this in the proper section (3rd Party Scripts) or actually posting / asking the actual developer(s) of RollingCurl for help, as they would know their system better than we would. Quote Link to comment https://forums.phpfreaks.com/topic/262402-get-and-post-request-in-php-with-rollingcurl-library/#findComment-1344779 Share on other sites More sharing options...
konkhra Posted May 11, 2012 Author Share Posted May 11, 2012 What is RollingCurl? Never heard of it. You would probably do better to either post this in the proper section (3rd Party Scripts) or actually posting / asking the actual developer(s) of RollingCurl for help, as they would know their system better than we would. RollingCurl is a way for processing multiple HTTP requests in parallel in PHP. Being a beginner in php I don't know how to use that library to fit my needs. I searched over the internet for similar examples but with no success Quote Link to comment https://forums.phpfreaks.com/topic/262402-get-and-post-request-in-php-with-rollingcurl-library/#findComment-1344813 Share on other sites More sharing options...
QuickOldCar Posted May 14, 2012 Share Posted May 14, 2012 Here is the basics to do multiple urls <?php function request_callback($response, $info) { print_r($info); echo "<hr>"; } require("RollingCurl.php"); echo "<hr>"; $urls = array("http://phpfreaks.com", "http://www.facebook.com", "http://www.yahoo.com", "http://www.youtube.com", "http://www.live.com", "http://www.wikipedia.com", "http://www.msn.com", "http://www.yahoo.co.jp", "http://www.myspace.com", "http://www.twitter.com", "http://www.microsoft.com"); $rc = new RollingCurl("request_callback"); $rc->window_size = 20; foreach ($urls as $url) { $request = new RollingCurlRequest($url); $rc->add($request); } $rc->execute(); ?> For parsing or other information needed for each url, you get it the same way as any other normal curl request. Add whatever you need in the request_callback function Quote Link to comment https://forums.phpfreaks.com/topic/262402-get-and-post-request-in-php-with-rollingcurl-library/#findComment-1345347 Share on other sites More sharing options...
QuickOldCar Posted May 14, 2012 Share Posted May 14, 2012 Here it is with using a text area for multiple urls, I didn't spend any time styling this or anything, but to show you how can do it. <form name="input" action="" method="post"> <textarea cols="100" rows="10" name="url" placeholder="Place urls each line" value="<?php echo $_POST['url'];?>"/><?php echo $_POST['url'];?></textarea> <input type="submit" value="fetch urls"/> </form> <?php if(isset($_POST['url']) && $_POST['url'] != ''){ function request_callback($response, $info) { print_r($info); echo "<hr>"; } $url_values = array(); $show_urls = str_replace(array(",","\r",",\n "," "), "|",$_POST['url']); $urls_array = explode("|",$show_urls); foreach($urls_array as $urls){ if($urls != ''){ $url_values[] = trim($urls); } } require("RollingCurl.php"); echo "<hr>"; $rc = new RollingCurl("request_callback"); $rc->window_size = 20; foreach ($url_values as $url) { $request = new RollingCurlRequest($url); $rc->add($request); } $rc->execute(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262402-get-and-post-request-in-php-with-rollingcurl-library/#findComment-1345361 Share on other sites More sharing options...
r3sk0 Posted October 27, 2012 Share Posted October 27, 2012 Moreover, If you need to use proxy- and useragent-lists, changing "on the fly", and some other stuff - you may need AngryCurl - the RollingCurl's fork, wich can be found here at github: https://github.com/2naive/AngryCurl and a bit described here(but just in Russian): http://stupid.su/php-curl_multi/?link Quote Link to comment https://forums.phpfreaks.com/topic/262402-get-and-post-request-in-php-with-rollingcurl-library/#findComment-1388183 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.