| 12345678910111213141516171819202122 |
- <?php
- namespace App\Services;
- use Illuminate\Support\Facades\Http;
- class HttpClientService
- {
- /**
- * 创建带标准头的HTTP客户端
- */
- public static function make(string $timeout = '10'): \Illuminate\Http\Client\PendingRequest
- {
- return Http::timeout((int) $timeout)
- ->withHeaders([
- 'Accept' => 'application/json',
- 'Content-Type' => 'application/json',
- 'User-Agent' => 'Laravel/' . (app()->version()),
- ])
- ->retry(2, 200);
- }
- }
|