-
Notifications
You must be signed in to change notification settings - Fork 0
/
notion.php
54 lines (47 loc) · 1.83 KB
/
notion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// _ _ _ _
// | \ | | | | (_)
// | \| | ___ | |_ _ ___ _ __
// | . ` |/ _ \| __| |/ _ \| '_ \
// | |\ | (_) | |_| | (_) | | | |
// \_| \_/\___/ \__|_|\___/|_| |_|
require("config.php");
// ***************** GET NOTION LISTE ORGANISATION DB ****************
function queryNotionDb($dbId){
$notionDB= "https://api.notion.com/v1/databases/";
$NOTION_AUTH = "secret_CBFKHdZXvcF7J54TqRyha6zU52IHrRYqQHcTzQPrvBi";
$c = curl_init($notionDB.$dbId."/query");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$headers = array(
'Authorization: Bearer '.$NOTION_AUTH,
'Notion-Version: 2022-06-28',
'Content-Type: application/json'
);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_POST, true);
$notionDBs = json_decode(curl_exec($c), true);
curl_close($c);
$notionDatas = [];
foreach($notionDBs["results"] as $no){
$tmp = [];
$tmp["notion-url"] = $no["url"];
if (isset($no['properties']['canal Slack'])) {
$richTextArray = $no['properties']['canal Slack']['rich_text'];
foreach ($richTextArray as $item) {
if (isset($item['text']['content'])) {
$tmp["slack-channel"] = $item['text']['content'];
}
}
};
if (isset($no['properties']['dossier client Google Drive'])) {
$richTextArray = $no['properties']['dossier client Google Drive']['rich_text'];
foreach ($richTextArray as $item) {
if (isset($item['text']['content'])) {
$tmp["gdrive-name"] = $item['text']['content'];
}
}
};
$notionDatas[] = $tmp;
};
return $notionDatas;
}