zlt / laravel-notion-viewer
使用 Laravel 获取 Notion 块
v0.0.2
2022-12-10 15:06 UTC
Requires
- php: ^8.1
- illuminate/http: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
This package is auto-updated.
Last update: 2024-09-10 18:41:37 UTC
README
这是一个用于获取 Notion 页面和块的 server side 包。
为了在您的应用程序中渲染 Notion 块,请考虑使用 npm 包 notion-viewer-client。
目录
先决条件
需求
"illuminate/support": "^8.0|^9.0",
"php": "^8.1",
"illuminate/http": "^8.0|^9.0"
您需要提供用于获取 Notion API 的 API 密钥。
如果您不知道如何获取 API 密钥,请参考此文档。
安装
- 通过 composer 安装包
composer require laravel-notion-viewer
- 发布配置文件
php artisan vendor:publish --tag=laravel-notion-viewer
以下路由将自动注册。
/laravel-notion-viewer/data/{id}
/laravel-notion-viewer/link-preview
配置文件将是
'API_KEY' => env('NOTION_API_KEY'), 'API_VERSION' => env('NOTION_API_VERSION'), // default '2022-06-28' 'cache' => [ // If you want to cache the response, set this to true 'enabled' => false, // specify cache time in seconds 'time' => 60, ]
使用
use Zlt\LaravelNotionViewer\Notion\Client;
-
获取 Notion 页面
Client::getPage('page-id');
-
获取块
Client::getBlocks('block-id');
-
获取带块的 Notion 页面
Client::getPageWithBlocks('page-id');
-
获取递归块
某些块有子块。要获取所有子块,请使用此方法。
Client::getRecursiveBlocks('block-id');
-
获取带递归块的页面
Client::getPageWithRecursiveBlocks('page-id');
故障排除
-
object_not_found 错误
如果您遇到
object_not_found错误,请检查您是否已授予您的集成访问权限到您的 Notion 页面。请参阅这里。
支持我
如果您想支持我,请通过 Binance 购买我一杯咖啡。
待办事项
- 添加测试
- 添加更多功能以涵盖所有 Notion API 端点