Skip to content

Commit 502515d

Browse files
committed
basic auth
1 parent 95950b9 commit 502515d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ composer require raph6/httprequest
1010
```php
1111
$http = new HttpRequest();
1212
$http->setUrl('http://localhost:8080')
13-
->setData(['foo' => 'bar'])
14-
->setHeaders(['token' => '123456'])
15-
->setUserAgent('PHP/Curl (https://github.com/raph6/httprequest)');
13+
->setData(['foo' => 'bar'])
14+
->setHeaders(['token' => '123456'])
15+
->setUserAgent('PHP/Curl (https://github.com/raph6/httprequest)')
16+
->setBasicAuth('username', 'password');
1617

1718
var_dump($http->post());
1819
// var_dump($http->get());

src/HttpRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct () {
2424

2525
public function setBasicAuth($username, $password) {
2626
curl_setopt($this->_ch, CURLOPT_USERPWD, $username . ":" . $password);
27+
return $this;
2728
}
2829

2930
public function setHeaders($headers = array())

0 commit comments

Comments
 (0)