PHPackages                             zgclives/bytedance - 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. [API Development](/categories/api)
4. /
5. zgclives/bytedance

ActiveLibrary[API Development](/categories/api)

zgclives/bytedance
==================

sdk for bytedance mini app

v1.0.3(4y ago)3401MITPHPPHP &gt;=7.2.0

Since Aug 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/zgclives/Bytedance)[ Packagist](https://packagist.org/packages/zgclives/bytedance)[ RSS](/packages/zgclives-bytedance/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

Bytedance 字节跳动接口
================

[](#bytedance-字节跳动接口)

说明
--

[](#说明)

大部分代码是引用了`cvoid/bytedance-mini-app`这位兄弟的包，有些接口不支持（例如分账），所以用了这位兄弟的包 做扩展，如有侵权，立马下架。

安装(Installation)
----------------

[](#安装installation)

```
composer require zgclives/bytedance
```

功能(Features)
------------

[](#功能features)

api实现是否完成getAccessTokenlogin-&gt;getAccessToken()☑️登录 - code2Sessionlogin-&gt;code2Session()☑️数据缓存 - setUserStorage数据缓存 - removeUserStorage创建二维码 - createQRCodetool-&gt;createQRCode☑️内容安全检测图片检测 V2订阅消息推送tool-&gt;sendSubscribedMessage☑️服务端预下单payment-&gt;createOrder☑️服务端支付回调payment-&gt;notify☑️订单查询payment-&gt;queryOrder☑️退款payment-&gt;createRefund☑️退款回调payment-&gt;refundNotify☑️查询退款payment-&gt;queryRefund☑️分账payment-&gt;createSettle☑️分账回调payment-&gt;settleNotify☑️查询分账payment-&gt;querySettle☑️服务商进件分账方进件使用(Usage)
---------

[](#使用usage)

### getApp

[](#getapp)

```
require_once __DIR__.'./vendor/autoload.php';

use \Bytedance\BytedanceApp;

$app = new \Bytedance\BytedanceApp('appId', 'secret', 'salt', 'token');
```

### 获取 AccessToken

[](#获取-accesstoken)

```
$response = $app->login->accessToken();

$access_token = $response->accessToken;
$expires_in = $response->expiresIn;
```

### 登录

[](#登录)

```
$response = $app->login->code2Session($code);

return [
    'session_key' => $response->sessionKey,
    'openid'      => $response->openId,
    'unionid'     => $response->unionId,
];
```

### 创建二维码

[](#创建二维码)

```
$access_token = $app->login->accessToken()->accessToken;
return $app->tool->createQRCode($access_token, $app->tool::APP_DOUYIN, 'pages/index/index');
```

### 订阅消息推送

[](#订阅消息推送)

```
$access_token = $app->login->accessToken()->accessToken;
return $app->tool->sendSubscribedMessage($access_token, $tpl_id, $open_id, $data, 'pages/index/index');
```

### 服务端预下单

[](#服务端预下单)

```
$response = $app->payment->createOrder($out_order_no, $total_amount, $subject, $body, $valid_time, $cp_extra, $notify_url);

return [
    'order_id'    => $response->orderId,
    'order_token' => $response->orderToken
];
```

### 订单查询

[](#订单查询)

```
$response = $app->payment->queryOrder($out_order_no);

return $response;
//[totalFee] => 2
//[orderStatus] => SUCCESS
//[payTime] => 2021-08-26 17:38:49
//[way] => 1
//[channelNo] => 4321001296202108269673188430
//[channelGatewayNo] => 12108260167652952855
```

### 退款

[](#退款)

```
$response = $app->payment->createOrder($out_order_no, $total_amount, $subject, $body, $valid_time, $cp_extra, $notify_url);

return [
    'order_id'    => $response->orderId,
    'order_token' => $response->orderToken
];
```

### 分账

[](#分账)

```
$response = $app->payment->createSettle($out_settle_no, $out_order_no, $settle_desc, $settle_params, $cp_extra, $notify_url);

return [
    'settle_no'     => $response->settleNo
];
```

### 分账查询

[](#分账查询)

```
$response = $app->payment->querySettle($out_order_no);

return [
    'settle_no'     => $response->settleNo,
    'settle_status' => $response->settleStatus,
    'settle_amount' => $response->settleAmount,
    'settle_detail' => $response->settleDetail,
    'settled_at'    => $response->settleAt,
    'rake'          => $response->rake,
    'commission'    => $response->commission,
    'cp_extra'      => $response->cpExtra,
];
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~66 days

Total

4

Last Release

1516d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/81785826?v=4)[zgc](/maintainers/zgclives)[@zgclives](https://github.com/zgclives)

---

Top Contributors

[![zgclives](https://avatars.githubusercontent.com/u/81785826?v=4)](https://github.com/zgclives "zgclives (3 commits)")[![id0612](https://avatars.githubusercontent.com/u/2449459?v=4)](https://github.com/id0612 "id0612 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zgclives-bytedance/health.svg)

```
[![Health](https://phpackages.com/badges/zgclives-bytedance/health.svg)](https://phpackages.com/packages/zgclives-bytedance)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[deeplcom/deepl-php

Official DeepL API Client Library

2616.2M66](/packages/deeplcom-deepl-php)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)

PHPackages © 2026

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