定制 carry0987/falcon 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

carry0987/falcon

最新稳定版本:1.0.4

Composer 安装命令:

composer require carry0987/falcon

包简介

Falcon - A versatile PHP framework designed for seamless integration of third-party social logins. Supports major services including Google, Facebook, Twitter, etc, delivering simple and secure authentication via a unified interface and design patterns.

README 文档

README

Packgist
Falcon is a versatile PHP framework designed for seamless integration of third-party social platform login mechanisms.
It offers simple and secure user authentication through a unified interface and design patterns, making it easy to implement and maintain.
Currently, it supports the following major services:

  • GitHub
  • Google
  • Facebook
  • Instagram
  • Twitter
  • Reddit
  • Discord
  • Line
  • Telegram

Whether you're developing a new application or enhancing an existing system, Falcon can help you quickly implement social login features while ensuring user data security and privacy.

Features

  • Unified Interface: Operate all supported social services using standardized methods.
  • Easy Integration: Integrate quickly into your project with intuitive configuration and clear documentation.
  • Security: Implements the best current security practices to safeguard the login process and data.
  • Flexible Design: Easily add or remove specific social services without affecting the existing system architecture.
  • Open Source Support: Benefit from the continuous improvements and support of the open-source community.

Installation

Install Falcon into your project with Composer:

composer require carry0987/falcon

Usage Example

First, set up the credentials and other configuration information for each third-party service in your project:

$config = [
    'providers' => [
        'github' => [
            'client_id' => 'your_github_client_id',
            'client_secret' => 'your_github_client_secret',
            'redirect_uri' => 'https://your-website.com/path/to/callback.php?provider=github'
        ],
        'line' => [
            'client_id' => 'your_line_client_id', // Channel ID
            'client_secret' => 'your_line_client_secret', // Channel secret
            'redirect_uri' => 'https://your-website.com/path/to/callback.php?provider=line'
        ],
        'telegram' => [
            'client_id' => 'your_telegram_client_id', // Bot username
            'client_secret' => 'your_telegram_client_secret', // Bot token
            'redirect_uri' => 'https://your-website.com/path/to/callback.php?provider=telegram'
        ],
        // Configuration for other third-party login providers...
    ],
];

Next, create an instance of Falcon and initiate the login process with the chosen third-party provider:

$falcon = new \carry0987\Falcon\Falcon($config);
$providerName = $_GET['provider'] ?? 'default';
$provider = $falcon->createProvider($providerName);

// Start the OAuth login process
if (!isset($_GET['code'])) {
    $loginUrl = $provider->authorize();
    // Redirect user to the login page
    header('Location: ' . $loginUrl);
    exit;
}

// Handle the callback and retrieve user information
if ($providerName === 'telegram') {
    // Special handling for Telegram login flow...
} else {
    $accessToken = $provider->getTokenWithAuthCode($_GET['code']);
    $user = $provider->getUser();
    
    // Output user information
    echo "<pre>" . print_r($user, true) . "</pre>";
}

To end the login session, you can revoke the access token:

if (isset($_GET['logout'])) {
    $provider->revokeAccessToken($_GET['access_token'] ?? null);
    // Redirect back to the login page or homepage
    header('Location: ?provider=' . $providerName);
    exit;
}

You can add more standard OAuth processing logic to your code, such as handling error states, redirecting to other pages, etc.

Support

If you have any issues, please open an issue on our GitHub repository.

Enjoy using Falcon in your project!

统计信息

  • 总下载量: 78
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-30