Skip to content

Commit 49a5f2e

Browse files
committed
Add support for getTopic
1 parent 8afe946 commit 49a5f2e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/DiscourseAPI.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private function _getRequest($reqString, $paramArray = null, $apiUser = 'system'
4545
http_build_query($paramArray)
4646
);
4747

48+
// TODO: move post requests to this auth also
4849
curl_setopt($ch, CURLOPT_HTTPHEADER, [
4950
"Api-Key: " . $this->_apiKey,
5051
"Api-Username: $apiUser"
@@ -91,7 +92,6 @@ private function _putpostRequest($reqString, $paramArray, $apiUser = 'system', $
9192
$apiUser
9293
);
9394

94-
9595
curl_setopt($ch, CURLOPT_URL, $url);
9696
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($paramArray));
9797
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -300,6 +300,18 @@ function createCategory($categoryName, $color, $textColor = '000000', $userName
300300
return $this->_postRequest('/categories', $params, $userName);
301301
}
302302

303+
/**
304+
* getTopic
305+
*
306+
* @param string $topicId id of topic
307+
*
308+
* @return mixed HTTP return code and API return object
309+
*/
310+
function getTopic($topicID)
311+
{
312+
return $this->_getRequest('/t/' . $topicID . '.json');
313+
}
314+
303315
/**
304316
* createTopic
305317
*
@@ -311,7 +323,6 @@ function createCategory($categoryName, $color, $textColor = '000000', $userName
311323
*
312324
* @return mixed HTTP return code and API return object
313325
*/
314-
315326
function createTopic($topicTitle, $bodyText, $categoryId, $userName, $replyToId = 0)
316327
{
317328
$params = array(
@@ -349,7 +360,6 @@ function watchTopic($topicId, $userName = 'system')
349360
*
350361
* @return mixed HTTP return code and API return object
351362
*/
352-
353363
function createPost($bodyText, $topicId, $userName)
354364
{
355365
$params = array(

0 commit comments

Comments
 (0)