phpvms/app/Console/Commands/TestApi.php

33 lines
700 B
PHP
Raw Normal View History

2017-12-31 01:56:38 +08:00
<?php
namespace App\Console\Commands;
use App\Console\Command;
2018-02-21 12:33:09 +08:00
use GuzzleHttp\Client;
2017-12-31 01:56:38 +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([
'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'));
echo $result->getBody();
2017-12-31 01:56:38 +08:00
}
}