Skip to content

Instantly share code, notes, and snippets.

@virus-warnning
Created April 23, 2025 02:45
Show Gist options
  • Save virus-warnning/3e041ea8a6dea6474f733ee3e955b24a to your computer and use it in GitHub Desktop.
Save virus-warnning/3e041ea8a6dea6474f733ee3e955b24a to your computer and use it in GitHub Desktop.
PHP 不使用 radius extension 完成認證
<?php
require_once 'vendor/autoload.php';
use Dapphp\Radius\Radius;
$username = '...';
$password = '...';
$host = '...';
$secret = '...';
$client = new Radius();
$client->setDebug(true);
$client->setServer($host)
->setSecret($secret);
$client->setMSChapPassword($password);
$authenticated = $client->accessRequest($username);
if ($authenticated === false) {
echo sprintf(
"Access-Request failed with error %d (%s).\n",
$client->getErrorCode(),
$client->getErrorMessage()
);
} else {
echo "Success! Received Access-Accept response from RADIUS server.\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment