Skip to content

Commit 341a74d

Browse files
committed
updated script
1 parent 21195ef commit 341a74d

File tree

5 files changed

+453
-426
lines changed

5 files changed

+453
-426
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"ext-curl": "*"
1616
},
1717
"autoload": {
18-
"classmap": ["lib/"]
18+
"psr-4": {
19+
"SujeetKumar\\CurlLib\\": "src/"
20+
}
1921
},
2022
"minimum-stability": "dev"
2123
}

example.php

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,53 @@
11
<?php
2-
require './lib/Curl.php';
2+
require './src/Curl.php';
3+
require './src/CurlException.php';
4+
5+
use SujeetKumar\CurlLib\Curl;
36

47
$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-
'http_version' => '1.1' // HTTP version (1.1, 1.0)
8+
'timeout' => 30, // time limit for request
9+
'strict_mode' => false, // whether CURLOPT_FAILONERROR or not
10+
'max_redirects' => 10, // number of redirections to follow
11+
'http_version' => '1.1' // HTTP version (1.1, 1.0)
912
));
1013

1114

1215
// simple GET request
1316
$res1 = $curl->get('http://example.com');
1417
//echo $res1;
15-
echo '<pre>'; print_r($curl->getInfo()); echo '</pre>';
18+
echo '<pre>';
19+
print_r($curl->getInfo());
20+
echo '</pre>';
1621

1722

1823
// simple POST request
19-
$res2 = $curl->post('http://example.com', array('name'=>'Sujeet', 'age'=>25), array(CURLOPT_TIMEOUT => 20));
24+
$res2 = $curl->post('http://example.com', array('name' => 'Sujeet', 'age' => 25), array(CURLOPT_TIMEOUT => 20));
2025
//echo $res2;
21-
echo '<pre>'; print_r($curl->getInfo()); echo '</pre>';
26+
echo '<pre>';
27+
print_r($curl->getInfo());
28+
echo '</pre>';
2229

2330

2431
// custom request
2532
$res3 = $curl->sendRequest('GET', 'http://example.com');
2633
//echo $res3;
27-
echo '<pre>'; print_r($curl->getInfo()); echo '</pre>';
34+
echo '<pre>';
35+
print_r($curl->getInfo());
36+
echo '</pre>';
2837

2938

3039
// custom request
3140
$res4 = $curl->setOptions(array(
32-
CURLOPT_POST => true,
33-
CURLOPT_POSTFIELDS => array('name'=>'Sujeet', 'age'=>25),
34-
CURLOPT_TIMEOUT => 25
41+
CURLOPT_POST => true,
42+
CURLOPT_POSTFIELDS => array('name' => 'Sujeet', 'age' => 25),
43+
CURLOPT_TIMEOUT => 25
3544
))->execute('http://example.com');
3645
//echo $res4;
37-
echo '<pre>'; print_r($curl->getInfo()); echo '</pre>';
46+
echo '<pre>';
47+
print_r($curl->getInfo());
48+
echo '</pre>';
3849

3950

40-
echo '<pre>'; print_r($curl->getHeaders('http://example.com')); echo '</pre>';
51+
echo '<pre>';
52+
print_r($curl->getHeaders('http://example.com'));
53+
echo '</pre>';

0 commit comments

Comments
 (0)