Search.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 Search extends Controller
  7. {
  8. public function main()
  9. {
  10. $kw = $this->getQuery()->string("kw") ?: $this->getQuery()->string("args_0");
  11. $bids = $this->getQuery()->string("bids");
  12. $cid = $this->getQuery()->string("cid");
  13. $request = [
  14. 'r' => 'l',
  15. 'u' => Site::getData("user_tag")
  16. ];
  17. if ($kw) {
  18. $request['kw'] = urldecode($kw);
  19. }
  20. if ($bids) {
  21. $request['bids'] = $bids;
  22. }
  23. if ($cid) {
  24. $request['cid'] = $cid;
  25. }
  26. $page = $this->getQuery()->string("args_1");
  27. if ($page){
  28. $request['page'] = $page;
  29. }
  30. $sort = $this->getQuery()->string("s");
  31. if ($sort) {
  32. $request['s'] = $sort;
  33. }
  34. $url = Site::getData('site_url') . "/tao.php?" . http_build_query($request);
  35. $content = Dataoke::parse(file_get_contents($url));
  36. $this->setCache($content);
  37. }
  38. }