Category.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Heanup\App\Api\Controller;
  3. use Heanup\App\Api\Config\Site;
  4. use Heanup\App\Api\Controller;
  5. use Heanup\App\Api\Model\Dataoke;
  6. class Category extends Controller
  7. {
  8. protected function main()
  9. {
  10. // $id = $this->getQuery()->intval("id");
  11. $id = $this->getQuery()->string("args_0");
  12. $page = $this->getQuery()->string("args_1");
  13. $request = [
  14. 'r' => 'l',
  15. 'site' => 'classify',
  16. 'cid' => $id,
  17. ];
  18. $bids = $this->getQuery()->string("bids");
  19. $original_id = $this->getQuery()->string("original_id");
  20. if ($bids) {
  21. $request['bids'] = $bids;
  22. }
  23. if ($original_id) {
  24. $request['original_id'] = $original_id;
  25. }
  26. if ($page) {
  27. $request['page'] = $page;
  28. }
  29. $sort = $this->getQuery()->string("s");
  30. if ($sort) {
  31. $request['s'] = $sort;
  32. }
  33. $url = Site::getData('site_url') . "/tao.php?" . http_build_query($request);
  34. $content= Dataoke::parse(file_get_contents($url));
  35. $this->setCache($content);
  36. }
  37. protected function after()
  38. {
  39. $id = $this->getQuery()->string("args_0");
  40. $page = $this->getQuery()->string("args_1");
  41. if ($page) {
  42. $site_url = Site::getData('site_url') . "/category/" . $id . "/page_" . $page . ".html";
  43. } else {
  44. $site_url = Site::getData('site_url') . "/category/" . $id . "/index.html";
  45. }
  46. $this->addSitemap($site_url);
  47. }
  48. }