Skip to content

Commit e53f592

Browse files
committed
Merge pull request #6 from php-mod/revert-3-feature/non-urlencoded-payloads
Revert "Add support for non urlencoded payloads"
2 parents 4996eec + c1413a3 commit e53f592

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ $curl->post('http://www.example.com/login/', array(
2323
'username' => 'myusername',
2424
'password' => 'mypassword',
2525
));
26-
// Or for json APIs
27-
$curl->post('http://www.example.com/login/', json_encode(array(
28-
'username' => 'myusername',
29-
'password' => 'mypassword',
30-
)));
3126
```
3227

3328
```php
@@ -63,22 +58,13 @@ $curl->put('http://api.example.com/user/', array(
6358
'first_name' => 'Zach',
6459
'last_name' => 'Borboa',
6560
));
66-
// Or for json APIs
67-
$curl->put('http://api.example.com/user/', json_encode(array(
68-
'first_name' => 'Zach',
69-
'last_name' => 'Borboa',
70-
)));
7161
```
7262

7363
```php
7464
$curl = new Curl\Curl();
7565
$curl->patch('http://api.example.com/profile/', array(
7666
'image' => '@path/to/file.jpg',
7767
));
78-
// Or for json APIs
79-
$curl->patch('http://api.example.com/profile/', json_encode(array(
80-
'image' => '@path/to/file.jpg',
81-
)));
8268
```
8369

8470
```php

src/Curl/Curl.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct() {
4747

4848
public function get($url, $data = array()) {
4949
if (count($data) > 0)
50-
$this->setopt(CURLOPT_URL, $url . '?' g. http_build_query($data));
50+
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
5151
else
5252
$this->setopt(CURLOPT_URL, $url);
5353
$this->setopt(CURLOPT_HTTPGET, TRUE);
@@ -57,40 +57,27 @@ public function get($url, $data = array()) {
5757
public function post($url, $data=array()) {
5858
$this->setopt(CURLOPT_URL, $url);
5959
$this->setopt(CURLOPT_POST, TRUE);
60-
if(is_array($data)){
61-
$data = http_build_query($data);
62-
}
60+
$data = http_build_query($data);
6361
$this->setopt(CURLOPT_POSTFIELDS, $data);
6462
$this->_exec();
6563
}
6664

6765
public function put($url, $data=array()) {
68-
$this->setopt(CURLOPT_URL, $url);
66+
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
6967
$this->setopt(CURLOPT_CUSTOMREQUEST, 'PUT');
70-
if(is_array($data)){
71-
$data = http_build_query($data);
72-
}
73-
$this->setopt(CURLOPT_POSTFIELDS, $data);
7468
$this->_exec();
7569
}
7670

7771
public function patch($url, $data=array()) {
7872
$this->setopt(CURLOPT_URL, $url);
7973
$this->setopt(CURLOPT_CUSTOMREQUEST, 'PATCH');
80-
if(is_array($data)){
81-
$data = http_build_query($data);
82-
}
83-
$this->setopt(CURLOPT_POSTFIELDS, $data);
74+
$this->setopt(CURLOPT_POSTFIELDS, $data);
8475
$this->_exec();
8576
}
8677

8778
public function delete($url, $data=array()) {
88-
$this->setopt(CURLOPT_URL, $url);
79+
$this->setopt(CURLOPT_URL, $url . '?' . http_build_query($data));
8980
$this->setopt(CURLOPT_CUSTOMREQUEST, 'DELETE');
90-
if(is_array($data)){
91-
$data = http_build_query($data);
92-
}
93-
$this->setopt(CURLOPT_POSTFIELDS, $data);
9481
$this->_exec();
9582
}
9683

0 commit comments

Comments
 (0)