If you want more of my pastes visit: https://randompaste.000webhostapp.com/index.html
--------------------------------------------------------------------------------------
view my last post at: https://bitbin.it/N3VCFOzC/
--------------------------------------------------------------------------------------
<?php
$api_url = "myurl";
$response = file_get_contents($api_url);
$my_array = json_decode($response, true);
?>
//Basic CURL example
// 1. Initialize
$ch = curl_init();
// 2. Set Options
// URL to send the request to
curl_setopt($ch, CURLOPT_URL, 'https://www.mysportsfeeds.com/api/feed/pull/nhl/2017-playoff/scoreboard.json?fordate=20170416');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
// Return instead of outputting directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set compression
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
// Set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Basic " . base64_encode('user' . ":" . 'password')
]);
// 3. Execute the request and fetch the response. Check for errors.
$resp = curl_exec($ch);
/* $gameScoreArray = $resp->scoreboard->gameScore;
for ( $i=0; $i<sizeof($gameScoreArray); $i++) {
echo "Away Score = " . $gameScoreArray->awayScore;
echo "Home Score = " . $gameScoreArray->homeScore;
} */
$json=json_decode($resp,true);
print_r($json);
var output = "";
$gameScoreArray = $resp['scoreboard']['gameScore'];
for ( $i=0; $i<sizeof($gameScoreArray); $i++ ) {
echo "Away Score = " . $gameScoreArray[$i]['awayScore'];
echo "Home Score = " . $gameScoreArray[$i]['homeScore'];
}
// Close request to clear up some resources
curl_close($ch);
?>