2017-12-31 01:56:38 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Console\Command;
|
2018-02-21 12:33:09 +08:00
|
|
|
use GuzzleHttp\Client;
|
2017-12-31 01:56:38 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class TestApi
|
|
|
|
*/
|
|
|
|
class TestApi extends Command
|
2017-12-31 01:56:38 +08:00
|
|
|
{
|
|
|
|
protected $signature = 'phpvms:test-api {apikey} {url}';
|
|
|
|
protected $httpClient;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run dev related commands
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->httpClient = new Client([
|
2018-03-20 09:50:40 +08:00
|
|
|
'headers' => [
|
|
|
|
'Authorization' => $this->argument('apikey'),
|
|
|
|
'Content-type' => 'application/json',
|
|
|
|
'X-API-Key' => $this->argument('apikey'),
|
2018-08-27 00:40:04 +08:00
|
|
|
],
|
2017-12-31 01:56:38 +08:00
|
|
|
]);
|
|
|
|
|
|
|
|
$result = $this->httpClient->get($this->argument('url'));
|
2017-12-31 03:31:11 +08:00
|
|
|
echo $result->getBody();
|
2017-12-31 01:56:38 +08:00
|
|
|
}
|
|
|
|
}
|