使用 Laravel 的 HTTP 客户端库 Guzzle
use Illuminate\Support\Facades\Http;
$response = Http::withOptions([
'verify' => false //禁用 SSL 验证
])->get('http://example.com/api/endpoint', [ //域名
'param' => '22222',//参数
]);
$json = $response->json();
POST请求
$response = Http::post('http://example.com/api/endpoint', [
'key1' => 'value1',
'key2' => 'value2',
// ... 其他参数
]);
// 如果需要获取响应内容并解析为 JSON
$data = $response->json();