Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $url = 'https://www.mysportsfeeds.com/api/feed/pull/nhl/2017-playoff/scoreboard.json?fordate=20170416';
- $username = 'username';
- $password = 'password';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
- //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- //curl_setopt($ch, CURLOPT_REFERER, $url);
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
- $result = curl_exec($ch);
- $info = curl_getinfo($ch);
- $nhl=json_decode($result,true);
- curl_close($ch);
- ?>
- <?php foreach ($nhl['scoreboard']['gameScore'] as $game) {
- echo $game['game']['awayTeam']['Name'] . $game['awayScore'] . ' to ' . $game['game']['homeTeam']['Name'] . $game['homeScore'] . "n";
- }
- <table class="table">
- <tbody>
- <?php foreach ($nhl['scoreboard']['gameScore'] as $game) {
- echo '<tr>';
- echo '<td><img src="images/used/sports/Untitled-3_13.png" alt="W3Schools.com" style="max-width:80%"></td>';
- echo '<td>' . $game['game']['awayTeam']['Name'] . '</td>';
- echo '<td class="bold"> ' . $game['awayScore'] . ' - ' . $game['homeScore'] . ' </td>';
- echo '<td>' . $game['game']['homeTeam']['Name'] . '</td>';
- echo '<td><img src="images/used/sports/Untitled-3_14.png" alt="W3Schools.com" style="max-width:80%"></td>';
- } ?>
- </tbody>
- </table>
- $json=json_decode($da_json,true);
- foreach ($json['scoreboard']['gameScore'] as $game) {
- echo $game['game']['awayTeam']['Name'] . $game['awayScore'] . ' to ' . $game['game']['homeTeam']['Name'] . $game['homeScore'] . "n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement