baiduCommand.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. class baiduCommand extends Command
  5. {
  6. /**
  7. * The name and signature of the console command.
  8. *
  9. * @var string
  10. */
  11. protected $signature = 'baidu';
  12. /**
  13. * The console command description.
  14. *
  15. * @var string
  16. */
  17. protected $description = '百度站长推送';
  18. /**
  19. * Create a new command instance.
  20. *
  21. * @return void
  22. */
  23. public function __construct()
  24. {
  25. parent::__construct();
  26. }
  27. /**
  28. * Execute the console command.
  29. *
  30. * @return mixed
  31. */
  32. public function handle()
  33. {
  34. $urls = array(
  35. 'https://www.jhcs888.com/#/Home',
  36. 'https://www.jhcs888.com/#/AboutUs',
  37. 'https://www.jhcs888.com/#/NewDetail?id=3',
  38. 'https://www.jhcs888.com/#/NewDetail?id=5',
  39. );
  40. $api = 'http://data.zz.baidu.com/urls?site=https://www.jhcs888.com&token=AhKx7OpIGiJFvpEK';
  41. $ch = curl_init();
  42. $options = array(
  43. CURLOPT_URL => $api,
  44. CURLOPT_POST => true,
  45. CURLOPT_RETURNTRANSFER => true,
  46. CURLOPT_POSTFIELDS => implode("\n", $urls),
  47. CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
  48. );
  49. curl_setopt_array($ch, $options);
  50. $result = curl_exec($ch);
  51. dd($result);
  52. }
  53. }