| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Controller;
- class Test extends Controller
- {
- public function index()
- {
- $data = $this->football();
- return $this->success($data);
- }
- function football()
- {
- $url = 'https://v3.football.api-sports.io/teams?id=33';
- $key = env("API_FOOTBALL_KEY",'');
- $options = [
- 'http' => [
- 'method' => 'GET',
- 'header' => "x-rapidapi-key: {$key}"
- ]
- ];
- $context = stream_context_create($options);
- $response = file_get_contents($url, false, $context);
- if ($response === FALSE) {
- die('Error occurred while fetching data');
- }
- return json_decode($response, true);
- }
- }
|