PHP code example of pnoeric / discourse-api-php
1. Go to this page and download the library: Download pnoeric/discourse-api-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pnoeric / discourse-api-php example snippets
// set up key in Discourse first - recommend system key for all users
$key = 'my-secret-discourse-api-key';
$hostname = 'forums.example.com';
$api = new \pnoeric\DiscourseAPI($hostname, $key);
// and you're off and running!
// look through the src/DiscourseAPI.php file for methods
// for example:
$results = $api->getTopTopics();
// if you aren't sure what the API returns from a call, just look at it:
$results = $api->getUserByDiscourseId( 1 );
var_dump($results);
// you can also get a lot of info from the tests (see tests/DiscourseApiTest.php).