1. Go to this page and download the library: Download timutech/codecombat-api 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/ */
timutech / codecombat-api example snippets
'providers' => [
// Other
TimuTech\CodeCombat\CodeCombatServiceProvider::class,
],
$codecombat = new CodeCombat(
{CLIENT_ID},
{CLIENT_SECRET},
{OAUTH_PROVIDER_ID});
$user = {A user from your system}
$combatUser = $codecombat->register([
'name' => $user->name, // UNIQUE Nick Name
'email' => $user->email, // NEW Email,
'role' => 'student' //or 'teacher'
]);
$token = {YOUR OAuth2 token, generated for your user from your server}
$codecombat->setAuth($token)->createIdentity($combatUser);
$handle = {UNIQUE Nick Name assigned earlier or the CodeCombat ID of the user, if you have it}
$combatUser = $codecombat->getUser($handle);
$token = {YOUR OAuth2 token, generated for your user from your server}
$url = $codecombat->setAuth($token)->redirect();