Add setURL examples

This commit is contained in:
Zach Borboa
2015-04-24 12:45:04 -07:00
parent 6c2b84862d
commit c6ea53b953
3 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ use \Curl\Curl;
$curl = new Curl();
$curl->download('https://php.net/images/logos/php-med-trans.png', function($instance, $tmpfile) {
$save_to_path = '/tmp/_' . basename($instance->url);
$save_to_path = '/tmp/' . basename($instance->url);
$fh = fopen($save_to_path, 'wb');
stream_copy_to_stream($tmpfile, $fh);
fclose($fh);
+18
View File
@@ -0,0 +1,18 @@
<?php
require '../src/Curl/Curl.php';
use \Curl\Curl;
// Retrieve first N pages of search results.
$pages = 10;
$q = 'coffee';
$curl = new Curl('https://www.example.com/search');
for ($i = 1; $i <= $pages; $i++) {
// https://www.example.com/search?q=coffee&page=N
$curl->get(array(
'q' => $q,
'page' => $i,
));
}
+19
View File
@@ -0,0 +1,19 @@
<?php
require '../src/Curl/Curl.php';
use \Curl\Curl;
// Retrieve first N pages of search results.
$pages = 10;
$q = 'coffee';
$curl = new Curl();
$curl->setURL('https://www.example.com/search');
for ($i = 1; $i <= $pages; $i++) {
// https://www.example.com/search?q=coffee&page=N
$curl->get(array(
'q' => $q,
'page' => $i,
));
}