Skip to content

Commit 5ddddad

Browse files
committed
Add APIKey authentication to PHP library
LMB-649
1 parent 5199bdc commit 5ddddad

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

NetLicensingClient/netlicensing.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,15 @@ class NetLicensing
1313

1414
private $curl = null;
1515

16-
public $apiKey;
17-
1816
/**
1917
* Initializes a NetLicensing object
2018
**/
2119
function __construct($apiKey)
2220
{
23-
$this->apiKey = $apiKey;
24-
2521
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'NetLicensing/PHP ' . PHP_VERSION . ' (http://netlicensing.labs64.com)';
2622

2723
$this->curl = new Curl();
24+
$this->curl->headers['Authorization'] = 'Basic ' . base64_encode("apiKey:" . $apiKey);
2825
$this->curl->headers['Accept'] = 'application/json';
2926
$this->curl->user_agent = $user_agent;
3027
}
@@ -45,9 +42,6 @@ function validate($productNumber, $licenseeNumber, $licenseeName = '')
4542
$licenseeName = $licenseeNumber;
4643
}
4744
$url = self::NLIC_BASE_URL . '/licensee/' . $licenseeNumber . '/validate?productNumber=' . $productNumber . '&name=' . $licenseeName;
48-
if (!empty($this->apiKey)) {
49-
$url .= '&apiKey=' . $this->apiKey;
50-
}
5145

5246
$response = $this->curl->get($url, $vars = array());
5347

0 commit comments

Comments
 (0)