FastComments.com

FastComments PHP SSO SDK


這是 FastComments 官方的 PHP SSO SDK。

用於 FastComments SSO 整合的 PHP SDK

程式碼庫

在 GitHub 上查看


安裝 Internal Link

composer require fastcomments/sso

使用方法 Internal Link

Simple SSO

Simple SSO 使用簡單,但安全性低於 Secure SSO:

use FastComments\SSO\FastCommentsSSO;
use FastComments\SSO\SimpleSSOUserData;

// Create user data
$userData = SimpleSSOUserData::create(
    'username123',
    'user@example.com',
    'https://example.com/avatar.png'
);

// With URL-based login/logout
$sso = FastCommentsSSO::createWithUrls(
    null,
    $userData,
    'https://example.com/login',
    'https://example.com/logout'
);

// Or with callbacks
$sso = FastCommentsSSO::createWithCallbacks(
    $userData,
    function($url) { /* Handle login */ },
    function($url) { /* Handle logout */ }
);

// Get the token to pass to FastComments
$token = $sso->prepareToSend();

Secure SSO

Secure SSO 透過 HMAC 驗證提供更高的安全性:

use FastComments\SSO\FastCommentsSSO;
use FastComments\SSO\SecureSSOUserData;

// Create user data
$userData = SecureSSOUserData::create(
    'user-123',
    'user@example.com',
    'username123',
    'https://example.com/avatar.png'
);

// Add optional data if needed
$userData->isAdmin = true;
$userData->groupIds = ['group-1', 'group-2'];

// Create the SSO object with your API key
$sso = FastCommentsSSO::createSecure('your-api-key', $userData);

// Get the token to pass to FastComments
$token = $sso->prepareToSend();

文件 Internal Link


有關 FastComments SSO 的完整文件,請參閱 FastComments 文件.

需要幫助?

如果您在使用 PHP SSO SDK 時遇到任何問題或有任何疑問,請:

貢獻

歡迎各種貢獻!請造訪 GitHub 儲存庫 以查看貢獻指南。