Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3.  
  4. $url = 'https://www.mysportsfeeds.com/api/feed/pull/nhl/2017-playoff/scoreboard.json?fordate=20170416';
  5.  
  6. $username = 'stephaniie';
  7. $password = 'linkin8508';
  8.  
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  13. //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  14. //curl_setopt($ch, CURLOPT_REFERER, $url);
  15.  
  16.  
  17. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  18. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  20. curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
  21.  
  22.  
  23.  
  24. $result = curl_exec($ch);
  25. curl_close($ch);
  26.  
  27. $data = json_decode($result, true);
  28. print_r($data);
  29.  
  30. $json=json_decode($result,true);
  31.  
  32. $gameScoreArray = $result['scoreboard']['gameScore'];
  33. foreach ($json['scoreboard']['gameScore'] as $game) {
  34.      echo $game['game']['awayTeam']['Name'] . $game['awayScore'] . ' to '  . $game['game']['homeTeam']['Name'] . $game['homeScore'] . "\n";
  35. }
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement