|
| 1 | +<?php |
| 2 | +require './lib/Curl.php'; |
| 3 | + |
| 4 | +$curl = new Curl(array( |
| 5 | + 'timeout' => 30, // time limit for request |
| 6 | + 'strict_mode' => false, // whether CURLOPT_FAILONERROR or not |
| 7 | + 'max_redirects' => 10 // number of redirections to follow |
| 8 | +)); |
| 9 | + |
| 10 | + |
| 11 | +// simple GET request |
| 12 | +$res1 = $curl->get('http://example.com'); |
| 13 | +//echo $res1; |
| 14 | +echo '<pre>'; print_r($curl->getInfo()); echo '</pre>'; |
| 15 | + |
| 16 | + |
| 17 | +// simple POST request |
| 18 | +$res2 = $curl->post('http://example.com', array('name'=>'Sujeet', 'age'=>25), array(CURLOPT_TIMEOUT => 20)); |
| 19 | +//echo $res2; |
| 20 | +echo '<pre>'; print_r($curl->getInfo()); echo '</pre>'; |
| 21 | + |
| 22 | + |
| 23 | +// custom request |
| 24 | +$res3 = $curl->sendRequest('GET', 'http://example.com'); |
| 25 | +//echo $res3; |
| 26 | +echo '<pre>'; print_r($curl->getInfo()); echo '</pre>'; |
| 27 | + |
| 28 | + |
| 29 | +// custom request |
| 30 | +$res4 = $curl->setOptions(array( |
| 31 | + CURLOPT_POST => true, |
| 32 | + CURLOPT_POSTFIELDS => array('name'=>'Sujeet', 'age'=>25), |
| 33 | + CURLOPT_TIMEOUT => 25 |
| 34 | +))->execute('http://example.com'); |
| 35 | +//echo $res4; |
| 36 | +echo '<pre>'; print_r($curl->getInfo()); echo '</pre>'; |
| 37 | + |
| 38 | + |
| 39 | +echo '<pre>'; print_r($curl->getHeaders('http://example.com')); echo '</pre>'; |
0 commit comments