PHP code example of roelmagdaleno / markdown-to-notion-blocks

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

    

roelmagdaleno / markdown-to-notion-blocks example snippets


use RoelMR\MarkdownToNotionBlocks\MarkdownToNotionBlocks;

$markdown = '# Hello, world!';
$notionBlocks = MarkdownToNotionBlocks::array($markdown);

print_r($notionBlocks);

use RoelMR\MarkdownToNotionBlocks\MarkdownToNotionBlocks;

$markdown = '# Hello, world!';
$notionBlocks = MarkdownToNotionBlocks::json($markdown);

echo $notionBlocks;

use RoelMR\MarkdownToNotionBlocks\MarkdownToNotionBlocks;

$markdown = '# Hello, world!';

$notionBlocks = MarkdownToNotionBlocks::array($markdown);

$notionBlocks[0]['heading_1']['rich_text'][0]['text']['content'] = 'My heading changed.';
$notionBlocks[0]['heading_1']['color'] = 'red';

echo json_encode($notionBlocks);

use RoelMR\MarkdownToNotionBlocks\MarkdownToNotionBlocks;

$markdown = file_get_contents($file_path);

$notion_blocks = MarkdownToNotionBlocks::array($markdown);

if (!$notion_blocks) {
    return false;
}

$notion_db_id = '101c7zs03d0680e6aa1cf27a0e61e8f4';

foreach ($notion_blocks as $notion_block) {
    append_blocks_to_notion_page($notion_db_id, $notion_block);
}