2017-12-31 01:56:38 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use App\Console\BaseCommand;
|
|
|
|
|
|
|
|
class TestApi extends BaseCommand
|
|
|
|
{
|
|
|
|
protected $signature = 'phpvms:test-api {apikey} {url}';
|
|
|
|
|
|
|
|
protected $httpClient;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run dev related commands
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->httpClient = new Client([
|
|
|
|
'headers' => [
|
|
|
|
'Authorization' => $this->argument('apikey'),
|
2017-12-31 03:31:11 +08:00
|
|
|
'Content-type' => 'application/json',
|
|
|
|
'X-API-Key' => $this->argument('apikey'),
|
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
|
|
|
}
|
|
|
|
}
|