PHP code example of digitalscout / api-client

1. Go to this page and download the library: Download digitalscout/api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalscout / api-client example snippets




$client = new DigitalScout\Api("api.hsgamecenter.com", $apiKey);

//create a game
$newGame = new DigitalScout\Models\Game([
		"Sport" => "Football",
		"StartTime" => new DateTime("2015-09-01T23:00:00.000Z")
		"Participants" => [
			['SchoolId' => $school1Id, 'Level' => 'Varsity', 'Gender' => 'Male'],
			['SchoolId' => $school2Id, 'Level' => 'Varsity', 'Gender' => 'Male']
		], 
		"HomeSchoolId" => $school1Id
	]);
	
$createdGame = $client->games->createGame($newGame);

//load a game
$loadedGame = $client->games->getGame($createdGame->Id);

//change the time for a game
$loadedGame->StartTime = new DateTime("2015-10-01T23:00:00.000Z");
$updatedGame = $client->games->updateGame($loadedGame);

//add scores to a game
$scoreUpdate = new DigitalScout\Models\GameScores([
		"Scores" => [
			["SchoolId" => $school1Id, "Period" => 1, "Score" => 0 ],
			["SchoolId" => $school1Id, "Period" => 2, "Score" => 7 ],
			["SchoolId" => $school1Id, "Period" => 3, "Score" => 0 ],
			["SchoolId" => $school1Id, "Period" => 4, "Score" => 7 ],
			["SchoolId" => $school2Id, "Period" => 1, "Score" => 7 ],
			["SchoolId" => $school2Id, "Period" => 2, "Score" => 0 ],
			["SchoolId" => $school2Id, "Period" => 3, "Score" => 7 ],
			["SchoolId" => $school2Id, "Period" => 4, "Score" => 0 ]			
		]
	]);

$client->games->updateGameScore($updatedGame->Id, $scoreUpdate);
bash
# Install Composer (Linux/OSX)
curl -sS https://getcomposer.org/installer | php