PHPackages                             lingxi/api-authentication - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lingxi/api-authentication

ActivePrivate

lingxi/api-authentication
=========================

v0.1.2(4y ago)3811.8k↓100%61PHPPHP ^7.3|^8.0

Since Nov 4Pushed 4y ago6 watchersCompare

[ Source](https://github.com/LingxiTeam/api-authentication)[ Packagist](https://packagist.org/packages/lingxi/api-authentication)[ RSS](/packages/lingxi-api-authentication/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (15)Used By (1)

api-authentication
==================

[](#api-authentication)

### 使用前

[](#使用前)

这个包是目前比较业界安全的加密实践，不仅仅作为 [lingxi api](https://open.lingxi360.com/category/docs) 的验证使用，有这种类似加密场景都可以使用这个 package，具体加密算法加文章最后。

### Install

[](#install)

```
composer require lingxi/api-authentication
```

### Usage

[](#usage)

```
use Lingxi\Signature\Authenticator;

require __dir__ . '/vendor/autoload.php';

$auther = new Authenticator('key', 'secret');
$data = [
    'id' => 'cawzyvopker1gdxeqx82w6qm2x5l73n8',
];
echo 'http://api.lingxi.com/v1/partner/cms/content/show?' . http_build_query($auther->getAuthParams($data)) . PHP_EOL;
```

> 为了方便使用，我们封装了 Api Client，你可以使用它直接调用接口，获取结果

```
use Lingxi\Signature\Client;

$apiClient = new Client(
    $partner->partner_key,
    $partner->partner_secret
);

try {
    $response = $apiClient->order('id', 'asc')->get('/contact/show');

    // get response data
    $data = $response->getResponseData();

    // 大部分接口，response data 包含 data 和 meta 两部分，可以：
    $data = $response->getData();
    $meta = $response->getMeta();

    // 也支持作为对象属性获取
    $data = $response->data;
    $meta = $response->meta;
} catch (\Exception $e) {
    // deal with it...
}
```

### 签名验证方式

[](#签名验证方式)

- 首先验证时间戳是否在当前时间 600s 内
- 其次验证 signature 是否正确

### signature 参数生成步骤

[](#signature-参数生成步骤)

设所有需要发送的数据为集合M，在集合M中增加当前时间戳stamp，随机字符串noncestr以及机构的api\_key，然后将集合M内非空参数值（或空数组）的参数按照参数名ASCII码从小到大排序（字典序），使用URL键值对的格式（即key1=value1&amp;key2=value2…）拼接成字符串stringA。 对stringA进行sha256哈希计算，秘钥api\_secret，得到signature值

### signature 参数验证步骤

[](#signature-参数验证步骤)

参数名ASCII码从小到大排序（字典序）； 如果参数的值为空（或空数组）不参与签名； 参数名区分大小写； 验证调用返回或主动通知签名时，传送的signature参数不参与签名，将生成的签名与该signature参数值作校验。 接口可能会增加字段，验证签名时必须支持增加的扩展字段

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 58.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~153 days

Recently: every ~373 days

Total

13

Last Release

1628d ago

PHP version history (2 changes)v0.0.1PHP &gt;=5.6

v0.1.2PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e299fd41aab7f893e95d127e4d86a76909fc310fcd72731581a2d7c11e4e101f?d=identicon)[RryLee](/maintainers/RryLee)

![](https://www.gravatar.com/avatar/f2b3997384bc6387894dd07850aaeb96109655a86e137929180edc9db71ed71a?d=identicon)[yekz](/maintainers/yekz)

---

Top Contributors

[![yekz](https://avatars.githubusercontent.com/u/3784533?v=4)](https://github.com/yekz "yekz (7 commits)")[![lingxi-iconfont](https://avatars.githubusercontent.com/u/29588939?v=4)](https://github.com/lingxi-iconfont "lingxi-iconfont (3 commits)")[![conybcc](https://avatars.githubusercontent.com/u/2978046?v=4)](https://github.com/conybcc "conybcc (1 commits)")[![sword-jin](https://avatars.githubusercontent.com/u/11711621?v=4)](https://github.com/sword-jin "sword-jin (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lingxi-api-authentication/health.svg)

```
[![Health](https://phpackages.com/badges/lingxi-api-authentication/health.svg)](https://phpackages.com/packages/lingxi-api-authentication)
```

###  Alternatives

[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
