Test.php 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Sport;
  5. use App\Services\ApiFootball\Client;
  6. use App\Services\FixtureService;
  7. use Illuminate\Support\Facades\DB;
  8. class Test extends Controller
  9. {
  10. public function index()
  11. {
  12. return $this->success([]);
  13. }
  14. function football($api, $params = [])
  15. {
  16. $url = config('services.api_football.host');
  17. $url .= $api;
  18. $url .= "?" . http_build_query($params);
  19. $key = config('services.api_football.key');
  20. $options = [
  21. 'http' => [
  22. 'method' => 'GET',
  23. 'header' => "x-rapidapi-key: {$key}"
  24. ]
  25. ];
  26. $context = stream_context_create($options);
  27. $response = file_get_contents($url, false, $context);
  28. if ($response === FALSE) {
  29. die('Error occurred while fetching data');
  30. }
  31. return json_decode($response, true);
  32. }
  33. }