diff --git a/README.md b/README.md index a1bb8a1..65808cd 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,10 @@ $ composer require elementsproject/lightning-strike-client-php ```php invoice([ 'msatoshi' => 50, 'metadata' => [ 'customer' => 'Satoshi', 'products' => [ 'potato', 'chips' ] ] ]); @@ -31,7 +34,7 @@ TODO: document missing methods ## Test ```bash -$ STRIKE_URL=http://localhost:8009 phpunit test +$ STRIKE_URL=http://api-token:[TOKEN]@localhost:8009 phpunit test ``` ## License diff --git a/client.php b/client.php index 3008645..0bd74d1 100644 --- a/client.php +++ b/client.php @@ -4,8 +4,13 @@ class LightningStrikeClient { protected $api; - public function __construct($url) { - $this->api = new RestClient([ 'base_url' => rtrim($url, '/') ]); + public function __construct($url, $api_token=null) { + $this->api = new RestClient([ + 'base_url' => rtrim($url, '/'), + 'curl_options' => $api_token ? [ + CURLOPT_USERPWD => 'api-token:' . $api_token + ] : [] + ]); } /**