elsayed85/notion

这是我包装的 Notion

1.0 2021-05-14 09:53 UTC

This package is auto-updated.

Last update: 2024-09-14 17:26:42 UTC


README

安装

您可以通过 composer 安装此包

composer require elsayed85/notion

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="Elsayed85\Notion\NotionServiceProvider" --tag="notion-config"

这是发布配置文件的内容

return [
    "base" => "https://api.notion.com",
    'version' => '2021-05-13'
];

将 Notion Api 添加到您的环境变量中

在 config/services.php 中

'notion' => [
        'client_id' => env('NOTION_CLIENT_ID'),
        'client_secret' => env('NOTION_CLIENT_SECRET'),
        'token' => env('NOTION_TOKEN')
]

在 .env 中添加

# for public
NOTION_CLIENT_ID=
NOTION_CLIENT_SECRET=

# for internal
NOTION_TOKEN=

用法

$notion = new Elsayed85\Internal\Notion();

$start_cursor = null;
$page_size = 20;

// https://developers.notion.com/reference/get-databases
$notion->databases($start_cursor , $page_size);

// https://developers.notion.com/reference/post-database-query
$notion->queryDatabase("2f611956-c64b-4588-ab64-2f013ac42527");

// https://developers.notion.com/reference/get-database
$notion->database("2f611956-c64b-4588-ab64-2f013ac42527");

// https://developers.notion.com/reference/get-users
$notion->users();

// https://developers.notion.com/reference/get-user
 $notion->user("73e41e87-0ae2-4ef0-bd21-a9d352c07a47");

 // https://developers.notion.com/reference/post-search
 $notion->search("hassan", 'last_edited_time');


// https://developers.notion.com/reference/get-page
 $notion->page("cdd93f5f-1626-4388-9a02-78779663a3aa")

// https://developers.notion.com/reference/post-page
 $notion->createPage(
        "2f611956-c64b-4588-ab64-2f013ac42527",
        "database_id",
        [
            'Name' => [
                'title' => [
                    0 => [
                        'text' => [
                            'content' => 'Tuscan Kale',
                        ],
                    ],
                ],
            ],
            'Email' => [
                'email' => "test@gmail.com",
            ],
        ],
        [
            0 => [
                'object' => 'block',
                'type' => 'heading_2',
                'heading_2' => [
                    'text' => [
                        0 => [
                            'type' => 'text',
                            'text' => [
                                'content' => 'Lacinato kale',
                            ],
                        ],
                    ],
                ],
            ],
            1 => [
                'object' => 'block',
                'type' => 'paragraph',
                'paragraph' => [
                    'text' => [
                        0 => [
                            'type' => 'text',
                            'text' => [
                                'content' => 'Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.',
                                'link' => [
                                    'url' => 'https://en.wikipedia.org/wiki/Lacinato_kale',
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ]
    );


// https://developers.notion.com/reference/patch-page
     $notion->updatePage(
        "cdd93f5f-1626-4388-9a02-78779663a3aa",
        [
            'Name' => [
                'title' => [
                    0 => [
                        'text' => [
                            'content' => 'Tuscan Kale',
                        ],
                    ],
                ],
            ],
            'Email' => [
                'email' => "test@gmail.com",
            ],
        ],
        [
            0 => [
                'object' => 'block',
                'type' => 'heading_2',
                'heading_2' => [
                    'text' => [
                        0 => [
                            'type' => 'text',
                            'text' => [
                                'content' => 'Lacinato kale',
                            ],
                        ],
                    ],
                ],
            ],
            1 => [
                'object' => 'block',
                'type' => 'paragraph',
                'paragraph' => [
                    'text' => [
                        0 => [
                            'type' => 'text',
                            'text' => [
                                'content' => 'Lacinato kale is a variety of kale with a long tradition in Italian cuisine, especially that of Tuscany. It is also known as Tuscan kale, Italian kale, dinosaur kale, kale, flat back kale, palm tree kale, or black Tuscan palm.',
                                'link' => [
                                    'url' => 'https://en.wikipedia.org/wiki/Lacinato_kale',
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ]
    );

变更日志

有关最近更改的更多信息,请参阅变更日志

贡献

有关详细信息,请参阅贡献指南

安全漏洞

有关报告安全漏洞的详细信息,请参阅我们的安全策略

鸣谢

许可证

MIT 许可证(MIT)。有关更多信息,请参阅许可证文件