承接 sudtechnology/sud-gip-auth-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sudtechnology/sud-gip-auth-php

最新稳定版本:v1.0.0.1

Composer 安装命令:

composer require sudtechnology/sud-gip-auth-php

包简介

PHP implementation of Sud GIP authentication system with JWT support

README 文档

README

Introduction

The Sud GIP Auth PHP SDK is a PHP library designed for implementing the Sud GIP authentication system, with support for JWT (JSON Web Token) authentication. This SDK provides functions such as generating authentication codes, server-to-server tokens (SSTokens), verifying tokens, and retrieving user IDs, making it convenient for developers to integrate Sud GIP's authentication services into PHP projects.

Features

  • Token Generation: Supports generating authentication codes and SSTokens, with the ability to set expiration durations.
  • Token Verification: Verifies the validity of authentication codes and SSTokens.
  • User ID Retrieval: Retrieves user IDs using authentication codes or SSTokens.

Installation

You can install this SDK using Composer. Run the following command in your project's root directory:

    composer require sudtechnology/sud-gip-auth-php

Usage

Initialization

First, you need to instantiate the SudGIPAuth class and pass in your application ID and application secret:

<?php
require 'vendor/autoload.php';

use Sud\Gip\Api\SudGIPAuth;

$appId = 'your_app_id';
$appSecret = 'your_app_secret';

$auth = new SudGIPAuth($appId, $appSecret);

Get Authentication Code

$uid = 'user_id';
$code = $auth->getCode($uid);

echo "Code: " . $code->code . "\n";
echo "Expire Date: " . $code->expireDate . "\n";

Get Server-to-Server Token (SSToken)

$uid = 'user_id';
$ssToken = $auth->getSSToken($uid);

echo "SSToken: " . $ssToken->token . "\n";
echo "Expire Date: " . $ssToken->expireDate . "\n";

Get User ID by Authentication Code

$code = 'your_auth_code';
$uidResponse = $auth->getUidByCode($code);

if ($uidResponse->isSuccess) {
    echo "User ID: " . $uidResponse->uid . "\n";
} else {
    echo "Error Code: " . $uidResponse->errorCode . "\n";
}

Get User ID by SSToken

$ssToken = 'your_sstoken';
$uidResponse = $auth->getUidBySSToken($ssToken);

if ($uidResponse->isSuccess) {
    echo "User ID: " . $uidResponse->uid . "\n";
} else {
    echo "Error Code: " . $uidResponse->errorCode . "\n";
}

Error Codes

Error Code Description
0 Success
1001 Token creation failed
1002 Token verification failed
1003 Token decoding failed
1004 Token is invalid
1005 Token has expired
1101 App data is invalid
9999 Unknown error

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-20