mirror of
https://github.com/yanyuandi/7.5inch_Multifunctional_E-Paper.git
synced 2026-05-12 06:24:43 +08:00
29 lines
632 B
PHP
29 lines
632 B
PHP
<?php
|
|
|
|
$url = 'https://v1.hitokoto.cn/';//
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
$data = json_decode($result, true);
|
|
|
|
if ($data['length'] < 12 || $data['length'] > 29) {
|
|
sleep(1); // 等待1秒钟
|
|
$result = file_get_contents($url);
|
|
$data = json_decode($result, true);
|
|
}
|
|
|
|
if ($data['from_who'] !== null) {
|
|
$data['from_who'] = '---' . $data['from_who'];
|
|
}
|
|
|
|
$result = json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
|
|
echo $result;
|
|
|
|
?>
|