Advertisement
vitozy

Laravel 7 - HTTP Client

Apr 30th, 2020
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. <?php
  2. use Illuminate\Http\Client\RequestException;
  3. use Illuminate\Support\Facades\Http;
  4.  
  5. try {
  6.   $response = Http::get('http://worldtimeapi.org/api/timezone/Europe');
  7.   $response->throw();
  8.  
  9.   $str = $response->body(); //body string lekérdezése
  10.   $arr = $response->json(); //json tömb lekérdezése (ha azt várjuk)
  11. } catch (RequestException $e) {
  12.   //exception kezelése
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement