forked from chuyskywalker/rolling-curl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
individualRequests.php
37 lines (32 loc) · 941 Bytes
/
individualRequests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require __DIR__ . '/../src/RollingCurl/RollingCurl.php';
require __DIR__ . '/../src/RollingCurl/Request.php';
$rollingCurl = new \RollingCurl\RollingCurl();
$sites = array(
'http://yahoo.com' => array(
CURLOPT_TIMEOUT => 15
),
'http://google.com' => array(
CURLOPT_TIMEOUT => 5
),
'http://hotmail.com' => array(
CURLOPT_TIMEOUT => 10
),
'http://msn.com' => array(
CURLOPT_TIMEOUT => 10
),
'http://reddit.com' => array(
CURLOPT_TIMEOUT => 25
),
);
foreach ($sites as $url => $options) {
$request = new \RollingCurl\Request($url);
$request->setOptions($options);
$rollingCurl->add($request);
}
$rollingCurl
->setCallback(function(\RollingCurl\Request $request, \RollingCurl\RollingCurl $rollingCurl) {
echo "Fetch complete for (" . $request->getUrl() . ")" . PHP_EOL;
})
->execute()
;