Skip to content

Commit c6ea53b

Browse files
committed
Add setURL examples
1 parent 6c2b848 commit c6ea53b

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

examples/download_file_with_callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
$curl = new Curl();
77
$curl->download('https://php.net/images/logos/php-med-trans.png', function($instance, $tmpfile) {
8-
$save_to_path = '/tmp/_' . basename($instance->url);
8+
$save_to_path = '/tmp/' . basename($instance->url);
99
$fh = fopen($save_to_path, 'wb');
1010
stream_copy_to_stream($tmpfile, $fh);
1111
fclose($fh);

examples/set_url_1.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
require '../src/Curl/Curl.php';
3+
4+
use \Curl\Curl;
5+
6+
// Retrieve first N pages of search results.
7+
$pages = 10;
8+
$q = 'coffee';
9+
10+
$curl = new Curl('https://www.example.com/search');
11+
12+
for ($i = 1; $i <= $pages; $i++) {
13+
// https://www.example.com/search?q=coffee&page=N
14+
$curl->get(array(
15+
'q' => $q,
16+
'page' => $i,
17+
));
18+
}

examples/set_url_2.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
require '../src/Curl/Curl.php';
3+
4+
use \Curl\Curl;
5+
6+
// Retrieve first N pages of search results.
7+
$pages = 10;
8+
$q = 'coffee';
9+
10+
$curl = new Curl();
11+
$curl->setURL('https://www.example.com/search');
12+
13+
for ($i = 1; $i <= $pages; $i++) {
14+
// https://www.example.com/search?q=coffee&page=N
15+
$curl->get(array(
16+
'q' => $q,
17+
'page' => $i,
18+
));
19+
}

0 commit comments

Comments
 (0)