calendar.php 913 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. $week = array();
  3. $week[0] = '日';
  4. $week[1] = '一';
  5. $week[2] = '二';
  6. $week[3] = '三';
  7. $week[4] = '四';
  8. $week[5] = '五';
  9. $week[6] = '六';
  10. $reply = '今天是 ' . date('Y年n月j日') . ' 星期' . $week[date('w')];
  11. $url = 'http://hl.zdic.net/j/gl/' . date('Y/n') . '.php';
  12. $response = ihttp_get($url);
  13. if (200 == $response['code'] && !empty($response['content'])) {
  14. preg_match('[{.*}]', $response['content'], $content);
  15. $data = json_decode("[{$content[0]}]", true);
  16. if (is_array($data)) {
  17. $today = date('Y-m-d');
  18. foreach ($data as $item) {
  19. if ($item['date'] == $today) {
  20. $reply .= "\n==================\n";
  21. $reply .= $item['nongliDay'];
  22. $reply .= "\n==================\n";
  23. $reply .= "宜: \n";
  24. $reply .= $item['yi'];
  25. $reply .= "\n==================\n";
  26. $reply .= "忌: \n";
  27. $reply .= $item['ji'];
  28. break;
  29. }
  30. }
  31. }
  32. }
  33. return $this->respText($reply);