Skip to content

Commit fbc5ee4

Browse files
authored
Merge pull request #13 from mentalstring/patch-1
Update API authentication method
2 parents 699ec82 + 6458c35 commit fbc5ee4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/DiscourseAPI.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ private function _getRequest($reqString, $paramArray = null, $apiUser = 'system'
3636
if ($paramArray == null) {
3737
$paramArray = array();
3838
}
39-
$paramArray['api_key'] = $this->_apiKey;
40-
$paramArray['api_username'] = $apiUser;
4139
$ch = curl_init();
4240
$url = sprintf(
4341
'%s://%s%s?%s',
@@ -46,7 +44,12 @@ private function _getRequest($reqString, $paramArray = null, $apiUser = 'system'
4644
$reqString,
4745
http_build_query($paramArray)
4846
);
49-
47+
48+
curl_setopt($ch, CURLOPT_HTTPHEADER, [
49+
"Api-Key: " . $this->_apiKey,
50+
"Api-Username: $apiUser"
51+
]);
52+
5053
if (!empty($this->_httpAuthName) && !empty($this->_httpAuthPass)) {
5154
curl_setopt($ch, CURLOPT_USERPWD, $this->_httpAuthName . ":" . $this->_httpAuthPass);
5255
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

0 commit comments

Comments
 (0)