PushAuthor.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\command;
  3. use app\model\star\StarTaskUser;
  4. use Symfony\Component\Console\Command\Command;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Output\OutputInterface;
  7. use yzh52521\EasyHttp\Http;
  8. class PushAuthor extends Command
  9. {
  10. protected static string $defaultName = 'push:author';
  11. protected static string $defaultDescription = '星川任务';
  12. protected function execute(InputInterface $input, OutputInterface $output): int
  13. {
  14. try {
  15. $nextPage = 1;
  16. $done = 0;
  17. while (is_numeric($nextPage)) {
  18. $resp = (new StarTaskUser)->page($nextPage,10)->select();
  19. if ($resp->isEmpty()) {
  20. $output->writeln("没有任务啦==".getDateFull());
  21. $nextPage = null;
  22. return true;
  23. }
  24. foreach ($resp as $key=>$val) {
  25. $resp = Http::asJson()->post("https://api.jiandaoyun.com/api/v1/automation/tenant/69dc899f71c9656940c3db33/hooks/69e07cb9d9016a4b9d9e4b140bb32ba471357f09758bdc49",$val->toArray())->array();
  26. print_r($resp);
  27. }
  28. $nextPage = $nextPage+1;
  29. $output->writeln("进入下一页=={$nextPage}==".getDateFull());
  30. }
  31. } catch (\Throwable $throwable) {
  32. echo getDateFull()."==报错啦===".$throwable->getFile()."\n";
  33. echo getDateFull()."==报错啦===".$throwable->getLine()."\n";
  34. echo getDateFull()."==报错啦===".$throwable->getMessage()."\n";
  35. }
  36. return true;
  37. }
  38. }