|
11 | 11 | /** |
12 | 12 | * A test script for the RollingCurlX class |
13 | 13 | * |
14 | | - * This example fetches the value of €1 on different currencies through the freecurrencyconverterapi.com |
| 14 | + * This script will fetch the value of €1 on different currencies through the freecurrencyconverterapi.com |
15 | 15 | * |
16 | 16 | * NOTE: freecurrencyconverterapi.com IS A FREE SERVICE, PLEASE, BE CONSIDERATE AND DON'T THROW TOO MANY REQUESTS |
17 | | - * AGAINST THEIR SERVERS. |
| 17 | + * AGAINST THEIR SERVERS. |
18 | 18 | * |
19 | 19 | * By Julio Foulquie <jfoulquie@gmail.com>, freely reusable. |
20 | 20 | */ |
|
33 | 33 | $curl_options = array( |
34 | 34 | CURLOPT_SSL_VERIFYPEER => FALSE, |
35 | 35 | CURLOPT_SSL_VERIFYHOST => FALSE, |
36 | | - CURLOPT_USERAGENT, 'RollingCurlX test script', |
| 36 | + CURLOPT_USERAGENT, '[RollingCurlX test script] - [!!!!! Ban this user agent if it becomes a hassle on your server !!!!!!]', |
37 | 37 | ); |
38 | 38 |
|
39 | 39 | echo "Using $max_requests concurrent requests at max." . PHP_EOL; |
|
46 | 46 | $rolling_curl->execute(); |
47 | 47 |
|
48 | 48 | // After running 'execute' the number of max_requests gets overwritten to the number of actual requests so reset it. |
49 | | -///TODO: Fix this on the class, _maxConcurrent should go back to its original value after an 'execute' call. |
50 | 49 | $rolling_curl->setMaxConcurrent($max_requests); |
51 | 50 | $rolling_curl->setOptions($curl_options); |
52 | 51 |
|
53 | | -foreach ($currencies as $currency => $data) { |
| 52 | + |
| 53 | +for($i = 0; $i < 20; $i++) { |
| 54 | + $currency = array_rand($currencies); |
54 | 55 | $user_data = array("1€ in $currency", $currency); |
55 | 56 | $search_url = $base_url . 'convert?q=EUR_'.$currency. '&compact=y'; |
56 | 57 | $rolling_curl->addRequest($search_url, NULL, 'on_request_done', $user_data); |
|
63 | 64 | * CALLBACKS |
64 | 65 | */ |
65 | 66 |
|
| 67 | +// Process the first call |
66 | 68 | function process_currencies($response, $url, $request_info, $user_data, $time) { |
67 | 69 | global $currencies; |
68 | 70 |
|
|
0 commit comments