You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
700 B
PHTML

<?php
declare(strict_types=1);
namespace App\Helper;
use GuzzleHttp\Client;
use Hyperf\Guzzle\HandlerStackFactory;
class Curl
{
public static function get(string $url) : array
{
$factory = new HandlerStackFactory();
$stack = $factory->create();
$client = make(Client::class, [
'config' => [
'handler' => $stack,
]
]);
$response = $client->get($url, ['timeout' => 2]);
if ($response->getStatusCode() === 200) {
return json_decode($response->getBody()->getContents(), true);
}
return [];
}
public static function post(string $url, array $data = [])
{
}
}