Skip to content
Browse files

made the example a little more interesting. now echos the page title …

…of the request along w/ the request $info array.
  • Loading branch information...
1 parent b126a16 commit bf3127cb32dd4ccb76bdb362b1c9a87a16cc9842 joshfraz committed Nov 29, 2009
Showing with 11 additions and 7 deletions.
  1. +11 −7 example.php
View
18 example.php
@@ -5,16 +5,10 @@
released under Apache License 2.0
*/
-// silly little example that fetches a bunch of sites in parrallel and echos the MD5 of the page content
+// a little example that fetches a bunch of sites in parallel and echos the page title and response info for each request
require("RollingCurl.php");
-// function that should process the returned content
-// pass this function name as a callback to your RC instance
-function request_callback($result) {
- echo md5($result)."<br />";
-}
-
// top 20 sites according to alexa (11/5/09)
$urls = array("http://www.google.com",
"http://www.facebook.com",
@@ -37,6 +31,16 @@ function request_callback($result) {
"http://www.wordpress.com",
"http://www.google.co.uk");
+function request_callback($response, $info) {
+ // parse the page title out of the returned HTML
+ if (eregi ("<title>(.*)</title>", $response, $out)) {
+ $title = $out[1];
+ }
+ echo "<b>$title</b><br />";
+ print_r($info);
+ echo "<hr>";
+}
+
$rc = new RollingCurl("request_callback");
$rc->window_size = 20;
foreach ($urls as $url) {

0 comments on commit bf3127c

Please sign in to comment.
Something went wrong with that request. Please try again.