PHP code example of thelufenk / notion

1. Go to this page and download the library: Download thelufenk/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/ */

    

thelufenk / notion example snippets


use Notion\Notion;

$databaseOptions = new Notion($token)
    ->database()
    ->ids();

use Notion\Notion;

$databaseOptions = new Notion($token)
    ->database($databaseId)
    ->query()
    ->get();

$nameFilter = (new Notion\Filters\TextFilter())
    ->equals('Name', 'Notion is awesome!');

$database = $client->database('e3161af3-ff12-43c5-9f42-02eea4ab4cbf')
  ->query()
  ->filter($nameFilter)
  ->get();

foreach ($database->pages as $page) {
  $name = $page->name;
  $status = $page->status;
}

$page = $client->page('9b0ff081-1af8-4751-92d6-9e07fbd5c20d')->get();

$name           = $page->name;          // Property: 'Name'
$showOnWebsite  = $page->showOnWebsite; // Property: 'Show on website'

$database = $client->database('e3161af3-ff12-43c5-9f42-02eea4ab4cbf')->get();

$page = $database->newPage();

$page->name = 'New page created with the Notion API';
$page->showOnWebsite = true;

$page->save();