PHP code example of linyows / notionslot
1. Go to this page and download the library: Download linyows/notionslot 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/ */
linyows / notionslot example snippets
use \Notionslot\Slot;
$config = [
'notion_token' => 'secret_**********************************',
'notion_db_id' => '123456aa-bc12-1234-5678-0987654321aa',
'site_domain' => 'foo.example',
'site_name' => 'My Foo',
'notify_to' => '[email protected] ',
'reply_to' => '[email protected] ',
'mail_from' => '[email protected] ',
];
$data = array_merge($_POST, ['ip' => $_SERVER['REMOTE_ADDR']]);
echo Slot::api($config, $_SERVER, $data);
use \Notionslot\Slot;
$config = [
'notion_token' => 'secret_**********************************',
'notion_db_id' => '123456aa-bc12-1234-5678-0987654321aa',
'site_domain' => 'foo.example',
'site_name' => 'My Foo',
'notify_to' => '[email protected] ',
'reply_to' => '[email protected] ',
'mail_from' => '[email protected] ',
];
$data = array_merge($_POST, ['ip' => $_SERVER['REMOTE_ADDR']]);
$res = [
'ok' => true,
'errors' => [],
];
$slot = new Slot($config);
if ($slot->sendHeader($_SERVER)->setData($data)->isValid()) {
$notionRes = $slot->notify()->reply()->save();
} else {
http_response_code(422);
$res = [
'ok' => false,
'errors' => $slot->errors(),
];
}
echo json_encode($res);