Reputation: 190
I am using Laravel's Http facade to make requests such as
Http::withHeaders(['user-agent' => 'My User agent'])->retry(3, 500)->get('https://example.com')->body();
And need to use proxy, which as per proxy provider's example should be set like this in case of PHP's curl
curl_setopt($curl, CURLOPT_PROXY, 'aaa');
curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'xxx:xxx');
Can these proxy options be somehow set with Laravel's Http class above?
Upvotes: 3
Views: 3615
Reputation: 8118
Http Facade is allowed you to use guzzle options, and guzzle has proxy option. So based on your code, you need to do like this:
Http::withHeaders(['user-agent' => 'My User agent'])
->withOptions(['proxy' => 'http://username:[email protected]:8080'])
->retry(3, 500)
->get('https://example.com')
->body();
Upvotes: 7