https://github.com/vinkashq/discourse-php
PHP library to authenticate your forum using Discourse Connect
https://github.com/vinkashq/discourse-php
discourse discourse-connect php php-library
Last synced: 11 months ago
JSON representation
PHP library to authenticate your forum using Discourse Connect
- Host: GitHub
- URL: https://github.com/vinkashq/discourse-php
- Owner: vinkashq
- License: mit
- Created: 2016-10-04T15:16:58.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-11-23T17:37:38.000Z (over 1 year ago)
- Last Synced: 2024-12-28T09:27:21.057Z (over 1 year ago)
- Topics: discourse, discourse-connect, php, php-library
- Language: PHP
- Homepage:
- Size: 30.3 KB
- Stars: 8
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# discourse-php
[](https://github.com/vinkashq/discourse-php/actions/workflows/tests.yml) [](https://packagist.org/packages/vinkas/discourse)
PHP library to authenticate your forum using Discourse Connect
## Installation
The package [`vinkas/discourse`](https://packagist.org/packages/vinkas/discourse) can be installed using composer via packagist.
```
composer require vinkas/discourse
```
## Documentation
### Creating a Discourse client
```php
$discourse = new Vinkas\Discourse\Client('discourse.example.com', true); // set true if ssl enabled
```
### Discourse Connect
```
$payload = $_GET['sso'];
$signature = $_GET['sig'];
$connect = $discourse->connect('SECRET', $payload, $signature);
if (!($connect->isValid())) {
header("HTTP/1.1 403 Forbidden");
echo("Bad Discourse Connect request");
die();
}
$userParams = array(
'external_id' => 'USER_ID',
'email' => 'EMAIL_ADDRESS',
'username' => 'USERNAME', // optional
'name' => 'FULL_NAME' // optional
// for more available fields https://meta.discourse.org/t/13045
);
$url = $connect->getResponseUrl($userParams)
header('Location: ' . $url);
exit(0);
```
Visit https://meta.discourse.org/t/setup-discourseconnect-official-single-sign-on-for-discourse-sso/13045 for more details about Discourse Connect.