最近做的小项目,需要用户提供一些信息,又不想再用数据库啥的,于是就找解决方案,比如在线的json解析,比如这家和这家。后面这个比较友好,只需要post一个id就可以得到数据:但是更新好,ID就又变了。
最近又找了Notion的database和其API
1. 创建 Internal Integration Token
https://developers.notion.com/docs/authorization
2. 链接 Connections
3. 查询
curl --location --request POST 'https://api.notion.com/v1/databases/755bbeef135147f9908d17b30ebea1b5/query' \
--header 'Authorization: Bearer secret_WPHxxxxxxvA89j95r' \
--header 'Content-Type: application/json' \
--header 'Notion-Version: 2022-02-22' \
--data-raw '{
"filter": {
"property": "Date",
"date": {
"equals": "2023-01-08"
}
}
}'
最后,客户又要求使用google sheet,我一看,直接html抓就可以了!
<?php
$client = new Client();
$url = 'https://docs.google.com/spreadsheets/d/1xIdXT4mTKHRulwJeHkzL_1dUuSsirnriGNHMvlOfdCc/htmlview';
$response = $client->get($url);
$html = (string)$response->getBody();
$htmlTmp = HtmlDomParser::str_get_html($html);
foreach ($htmlTmp->find('tbody tr') as $e) {
$meta[$e->find('td',0)->plaintext . $e->find('td',1)->plaintext] = $e->find('td',2)->plaintext;
}
$descA = $meta[date('n-j-Y') . 'a']??'';
$descB = $meta[date('n-j-Y') . 'b']??'';
$descC = $meta[date('n-j-Y') . 'c']??'';