Api.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Heanup\App\Api\Controller;
  3. use Heanup\App\Api\Config\Code;
  4. use Heanup\App\Api\Controller;
  5. use Heanup\App\Api\Package\Database\Num;
  6. use Heanup\Library\Sms\SmsFree;
  7. class Api extends Controller
  8. {
  9. protected function main()
  10. {
  11. $do = $this->getRequest()->string("do", "Country");
  12. $lib = new SmsFree();
  13. if ($do == "Country") {
  14. $data = $lib->getCountry();
  15. $data = array_map(function ($a) {
  16. $a['flag'] = "http://sms.x.97admin.com/flag/" . $a['flag'] . ".png";
  17. return $a;
  18. }, $data);
  19. $this->showSuccess($data);
  20. }
  21. if ($do = "List") {
  22. $country = $this->getQuery()->string("Country");
  23. if ($country) {
  24. $where = ['country' => $country];
  25. } else {
  26. $where = [];
  27. }
  28. $page = $this->getQuery()->intval("page", 1);
  29. $pgSize = 20;
  30. $data = Num::getPageList($where, "", $page, $pgSize, ['id' => true]);
  31. $data = array_map(function ($a) {
  32. $a['flag'] = "http://sms.x.97admin.com" . Code::getData($a['country'])['flag'];
  33. return $a;
  34. }, $data['data']);
  35. $this->showSuccess($data);
  36. }
  37. }
  38. }