Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 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 = 'username';
  7. $password = 'password';
  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. $result = curl_exec($ch);
  23. $info = curl_getinfo($ch);
  24. $nhl=json_decode($result,true);
  25. curl_close($ch);
  26. ?>
  27.  
  28. <?php foreach ($nhl['scoreboard']['gameScore'] as $game) {
  29. echo $game['game']['awayTeam']['Name'] . $game['awayScore'] . ' to ' . $game['game']['homeTeam']['Name'] . $game['homeScore'] . "n";
  30. }
  31.  
  32. <table class="table">
  33. <tbody>
  34. <?php foreach ($nhl['scoreboard']['gameScore'] as $game) {
  35. echo '<tr>';
  36. echo '<td><img src="images/used/sports/Untitled-3_13.png" alt="W3Schools.com" style="max-width:80%"></td>';
  37. echo '<td>' . $game['game']['awayTeam']['Name'] . '</td>';
  38. echo '<td class="bold"> ' . $game['awayScore'] . ' - ' . $game['homeScore'] . ' </td>';
  39. echo '<td>' . $game['game']['homeTeam']['Name'] . '</td>';
  40. echo '<td><img src="images/used/sports/Untitled-3_14.png" alt="W3Schools.com" style="max-width:80%"></td>';
  41. } ?>
  42. </tbody>
  43. </table>
  44.  
  45. $json=json_decode($da_json,true);
  46. foreach ($json['scoreboard']['gameScore'] as $game) {
  47. echo $game['game']['awayTeam']['Name'] . $game['awayScore'] . ' to ' . $game['game']['homeTeam']['Name'] . $game['homeScore'] . "n";
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement