0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Notion文献管理ツールちゃん改善日記

0
Posted at

はじめに

以下の記事の続きです。

今日は 
1.NotionAPIのシークレットキーを、ハードコーディングではなくDBから読み込む形に変更
2.完了画面に、いま作成したページに飛べるリンクを置く
をしました。

1.NotionAPIのシークレットキー

insert.phpの冒頭でDB接続を行い、DBに格納したAPIのシークレットキーをとってきて、配列に格納し、値を取り出すようにしました。
DBとの対話が初めて叶ってうれしいです、会話してくれてありがとう。

//DB接続
$DB_DATABASE = 'reftion';
$DB_USERNAME = 'XXXX';
$DB_PASSWORD = 'XXXX';
$DB_OPTION = 'charset=utf8';
$PDO_DSN = "mysql:host=localhost;dbname=" . $DB_DATABASE . ";" . $DB_OPTION;
$db = new PDO($PDO_DSN, $DB_USERNAME, $DB_PASSWORD);
//notion_token読み込み
$stmt=$db->prepare('SELECT value FROM manage WHERE name=\'notion_token\';');
$stmt->execute();
$notion_token_array=$stmt->fetch(PDO::FETCH_BOTH);

define('NOTION_TOKEN', $notion_token_array['value']);

2.完了画面

前回つくった完了画面は以下のような感じでしたが、せめてURLがリンクになっていると直接飛べて便利ですよね。
image.png

なので、こうして、

<p><?php  echo $res_cite_array['name'].'を登録しました。';?></p>
<a href="<?php echo $res_notion_array['url']?>">登録したページはこちらから確認してください。</a> 

こうしました。ちゃんとリンクを押すと、作ったページに飛びます。便利!

image.png

今日はここまでです。
これ、どこかのサーバにあげたとしたら、誰でも私のDBにガンガン挿入できちゃうじゃ~んと思ったので、つぎはログイン機能を作ろうと思います。(いまはローカルで毎回立ち上げてます)

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?