PHP code example of elsayed85 / notion
1. Go to this page and download the library: Download elsayed85/notion library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
elsayed85 / notion example snippets
return [
"base" => "https://api.notion.com",
'version' => '2021-05-13'
];
$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' => "[email protected] ",
],
],
[
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' => "[email protected] ",
],
],
[
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',
],
],
],
],
],
],
]
);
bash
php artisan vendor:publish --provider="Elsayed85\Notion\NotionServiceProvider" --tag="notion-config"