Skip to content

Commit 72fc428

Browse files
committed
feat: add document
1 parent 7339598 commit 72fc428

File tree

4 files changed

+157
-15
lines changed

4 files changed

+157
-15
lines changed

README-CN.md

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,63 @@
1515
# 非官方 Suno PHP-SDK
1616
这是一个基于 PHP 的非官方 Suno API;它为所有 Suno 接口提供支持。
1717

18-
## 安装
18+
## 安装 🔨
1919

2020
```bash
2121
composer require yunzhiyike/suno-ai-sdk
2222
```
2323

24-
## 方法
25-
-[x] `generateMusic` > [说明: 生成音乐, 返回 `uid` ]
26-
-[x] `refreshSession` > [说明: 延长会话时间, 返回 `PersonalInfoEntity` ]
27-
-[x] `getUserInfoByEmail` > [说明: 通过电子邮件获取用户信息, 返回 `PersonalInfoEntity` ]
28-
-[x] `getWorkList` > [说明:获取生成的音乐列表, 返回 `WorkEntity[]` ]
29-
-[x] `getAvailableTimes` > [说明: 获取可用次数, 返回 `int` ]
24+
## 方法 📖
25+
26+
- [x] `generateMusic` [说明: 生成音乐, 返回 `uid` ]
27+
- [x] `refreshSession` [说明: 延长会话时间, 返回 `PersonalInfoEntity` ]
28+
- [x] `getUserInfoByEmail` [说明: 通过电子邮件获取用户信息, 返回 `PersonalInfoEntity` ]
29+
- [x] `getWorkList` [说明:获取生成的音乐列表, 返回 `WorkEntity[]` ]
30+
- [x] `getAvailableTimes` [说明: 获取可用次数, 返回 `int` ]
31+
32+
33+
## Cookie提取 🚗
34+
35+
> 在此之前你需要先登录!
36+
37+
![img_1.png](img_1.png)
38+
39+
40+
## 示例 🌲
41+
```php
42+
<?php
43+
44+
declare(strict_types=1);
45+
/**
46+
* This file is part of Yunzhiyike
47+
*/
48+
49+
namespace Yunzhiyike\Test;
50+
51+
use PHPUnit\Framework\TestCase;
52+
use Yunzhiyike\SunoAiSdk\SunoAi;
53+
54+
/**
55+
* @internal
56+
* @coversNothing
57+
*/
58+
class SunoAiTest extends TestCase
59+
{
60+
public function test()
61+
{
62+
$cookie = 'your suno-ai cookie';
63+
$timeOut = 60;
64+
$sunoApi = new SunoAi($cookie, $timeOut);
65+
$info = $sunoApi->refreshSession();
66+
$userInfo = $sunoApi->getUserInfoByEmail($info->getEmail());
67+
$page = 1;
68+
$res = $sunoApi->getWorkList($userInfo->getUserId(), $page);
69+
foreach ($res as $r) {
70+
var_dump($r);
71+
}
72+
var_dump($sunoApi->getAvailableTimes($userInfo->getUserId()));
73+
var_dump($sunoApi->generateMusic($userInfo->getUserId(), 'music title', 'music text', 'music tags', true));
74+
}
75+
}
76+
77+
```

README-JP.md

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,56 @@ composer require yunzhiyike/suno-ai-sdk
2222
```
2323

2424
## メソッド
25-
-[x] `generateMusic` > [記述: ジェネレート・ミュージック, 戻る, `uid` ]
26-
-[x] `refreshSession` > [記述: セッション生存時間の延長, 戻る `PersonalInfoEntity` ]
27-
-[x] `getUserInfoByEmail` > [記述: 電子メールによるユーザー情報の取得, 戻る `PersonalInfoEntity` ]
28-
-[x] `getWorkList` > [記述: 生成された楽曲リストの取得, 戻る `WorkEntity[]` ]
29-
-[x] `getAvailableTimes` > [記述: 利用可能回数取得, 戻る `int` ]
25+
26+
- [x] `generateMusic` [記述: ジェネレート・ミュージック, 戻る, `uid` ]
27+
- [x] `refreshSession` [記述: セッション生存時間の延長, 戻る `PersonalInfoEntity` ]
28+
- [x] `getUserInfoByEmail` [記述: 電子メールによるユーザー情報の取得, 戻る `PersonalInfoEntity` ]
29+
- [x] `getWorkList` [記述: 生成された楽曲リストの取得, 戻る `WorkEntity[]` ]
30+
- [x] `getAvailableTimes` [記述: 利用可能回数取得, 戻る `int` ]
31+
32+
33+
## Cookie 引き出す 🚗
34+
35+
> 在此之前你需要先登录!
36+
37+
![img_1.png](img_1.png)
38+
39+
40+
## 典型例 🌲
41+
```php
42+
<?php
43+
44+
declare(strict_types=1);
45+
/**
46+
* This file is part of Yunzhiyike
47+
*/
48+
49+
namespace Yunzhiyike\Test;
50+
51+
use PHPUnit\Framework\TestCase;
52+
use Yunzhiyike\SunoAiSdk\SunoAi;
53+
54+
/**
55+
* @internal
56+
* @coversNothing
57+
*/
58+
class SunoAiTest extends TestCase
59+
{
60+
public function test()
61+
{
62+
$cookie = 'your suno-ai cookie';
63+
$timeOut = 60;
64+
$sunoApi = new SunoAi($cookie, $timeOut);
65+
$info = $sunoApi->refreshSession();
66+
$userInfo = $sunoApi->getUserInfoByEmail($info->getEmail());
67+
$page = 1;
68+
$res = $sunoApi->getWorkList($userInfo->getUserId(), $page);
69+
foreach ($res as $r) {
70+
var_dump($r);
71+
}
72+
var_dump($sunoApi->getAvailableTimes($userInfo->getUserId()));
73+
var_dump($sunoApi->generateMusic($userInfo->getUserId(), 'music title', 'music text', 'music tags', true));
74+
}
75+
}
76+
77+
```

README.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,63 @@ English | [中文](./README-CN.md) | [日本語](./README-JP.md)
1515
# Unofficial Suno PHP-SDK
1616
This is an unofficial Suno API based on PHP; it provides support for all Suno interfaces.
1717

18-
## Installation
18+
## Installation 🔨
1919

2020
```bash
2121
composer require yunzhiyike/suno-ai-sdk
2222
```
2323

24-
## Methods
24+
## Methods 📖
2525

2626
- [x] `generateMusic` [description: generate music, return `uid` ]
27-
2827
- [x] `refreshSession` [description: Increase session survival time, return `PersonalInfoEntity` ]
2928
- [x] `getUserInfoByEmail` [description: Obtaining user information via e-mail, return `PersonalInfoEntity` ]
3029
- [x] `getWorkList` [description: Obtaining generated music list, return `WorkEntity[]` ]
3130
- [x] `getAvailableTimes` [description: Getting the number of times available, return `int` ]
31+
32+
33+
## Cookie Extraction 🚗
34+
35+
> Before that you need to login!
36+
37+
![img_1.png](img_1.png)
38+
39+
40+
## Demo 🌲
41+
```php
42+
<?php
43+
44+
declare(strict_types=1);
45+
/**
46+
* This file is part of Yunzhiyike
47+
*/
48+
49+
namespace Yunzhiyike\Test;
50+
51+
use PHPUnit\Framework\TestCase;
52+
use Yunzhiyike\SunoAiSdk\SunoAi;
53+
54+
/**
55+
* @internal
56+
* @coversNothing
57+
*/
58+
class SunoAiTest extends TestCase
59+
{
60+
public function test()
61+
{
62+
$cookie = 'your suno-ai cookie';
63+
$timeOut = 60;
64+
$sunoApi = new SunoAi($cookie, $timeOut);
65+
$info = $sunoApi->refreshSession();
66+
$userInfo = $sunoApi->getUserInfoByEmail($info->getEmail());
67+
$page = 1;
68+
$res = $sunoApi->getWorkList($userInfo->getUserId(), $page);
69+
foreach ($res as $r) {
70+
var_dump($r);
71+
}
72+
var_dump($sunoApi->getAvailableTimes($userInfo->getUserId()));
73+
var_dump($sunoApi->generateMusic($userInfo->getUserId(), 'music title', 'music text', 'music tags', true));
74+
}
75+
}
76+
77+
```

img_1.png

441 KB
Loading

0 commit comments

Comments
 (0)