Browse Source

no message

sys 2 years ago
parent
commit
336ab35ebd
3 changed files with 69 additions and 0 deletions
  1. 4 0
      .gitignore
  2. 61 0
      app/Console/Commands/baiduCommand.php
  3. 4 0
      app/Console/Kernel.php

+ 4 - 0
.gitignore

@@ -13,3 +13,7 @@ npm-debug.log
 yarn-error.log
 /.idea
 /.vscode
+.htaccess
+.user.ini
+404.html
+index.html

+ 61 - 0
app/Console/Commands/baiduCommand.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace App\Console\Commands;
+
+
+use Illuminate\Console\Command;
+class baiduCommand extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'baidu';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '百度站长推送';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $urls = array(
+            'https://www.jhcs888.com/#/Home',
+            'https://www.jhcs888.com/#/AboutUs',
+            'https://www.jhcs888.com/#/NewDetail?id=3',
+            'https://www.jhcs888.com/#/NewDetail?id=5',
+        );
+        $api = 'http://data.zz.baidu.com/urls?site=https://www.jhcs888.com&token=AhKx7OpIGiJFvpEK';
+        $ch = curl_init();
+        $options =  array(
+            CURLOPT_URL => $api,
+            CURLOPT_POST => true,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_POSTFIELDS => implode("\n", $urls),
+            CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
+        );
+        curl_setopt_array($ch, $options);
+        $result = curl_exec($ch);
+        dd($result);
+
+    }
+}

+ 4 - 0
app/Console/Kernel.php

@@ -2,11 +2,15 @@
 
 namespace App\Console;
 
+use App\Console\Commands\baiduCommand;
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
 class Kernel extends ConsoleKernel
 {
+    protected $commands=[
+      baiduCommand::class
+    ];
     /**
      * Define the application's command schedule.
      *