12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Console\Commands;
- use App\Models\NewsModels\News;
- 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 = [
- 'https://www.jhcs888.com/#/Home',
- 'https://www.jhcs888.com/#/AboutUs',
- 'https://www.jhcs888.com/#/Cooperation',
- 'https://www.jhcs888.com/#/News',
- 'https://www.jhcs888.com/#/Contact',
- ];
- $news=News::where('is_del',0)->select(['id'])->get();
- foreach ($news as $new){
- $urls[]='https://www.jhcs888.com/#/NewDetail?id='.$new->{'id'};
- }
- $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);
- }
- }
|