Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bacherino's avatar

Sending a request to external api with shared hosting's ip.

Is it possible with laravel ?

I've tried so many things but couldn't figure it out.

Someone please help me :)

0 likes
7 replies
LaryAI's avatar
Level 58

Yes, it is possible to send a request to an external API with Laravel. You can use Laravel's built-in HTTP client or a third-party package like Guzzle to make the request. However, if you are using shared hosting, you may need to check with your hosting provider to ensure that outgoing requests are allowed from your server's IP address.

Here's an example of using Laravel's HTTP client to make a GET request to an external API:

$response = Http::get('https://api.example.com/data');
$data = $response->json();

And here's an example using Guzzle:

$client = new \GuzzleHttp\Client();
$response = $client->get('https://api.example.com/data');
$data = json_decode($response->getBody(), true);

Remember to replace the API endpoint URL with the actual URL of the API you want to call.

vincent15000's avatar

Why wouldn't it not be possible ?

Sending HTTP is not dependant from the type of hosting.

Bacherino's avatar

@vincent15000 The thing is i should create a cron and that cron must be get data from external api but beside this situation the other site has firewall and my shared hosting's ip is declared as white flag. So i though if i send that request as my own server my problem will be fixed. Am i thinking wrong ?

1 like
Bacherino's avatar

@vincent15000 But how can i pass this issue because only way to pass firewall is sending that request with my own hosting not my local pc i can't find the solution...

1 like

Please or to participate in this conversation.