1. Go to this page and download the library: Download asciisd/pelican 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/ */
asciisd / pelican example snippets
use Asciisd\Copytrade\Facades\Copytrade;
// 1. Log in and get a token
$token = Copytrade::auth()->login('[email protected]', 'secret-password');
// 2. Scope the SDK to that token
$copytrade = Copytrade::withToken($token->accessToken);
// 3. Call the API through the domain services
$user = $copytrade->profiles()->getUserInfo();
$profile = $copytrade->profiles()->getProfile($user->profileId);
$copiers = $copytrade->copiers()->getCopiers($user->profileId);
$strategies = $copytrade->strategies()->getStrategies($user->profileId);
use Asciisd\Copytrade\Facades\Copytrade;
$token = Copytrade::auth()->login('[email protected]', 'secret-password');
$token->accessToken; // "eyJhbGciOi..." — use this for API calls
$token->refreshToken; // used to renew the access token
$token->expiresIn; // lifetime in seconds (e.g. 3600)
$token->expiresAt; // CarbonImmutable expiry timestamp
$token->tokenType; // "Bearer"
use Asciisd\Copytrade\Exceptions\AuthenticationException;
try {
$token = Copytrade::auth()->login($email, $password);
} catch (AuthenticationException $e) {
// e.g. "Login failed: invalid email or password."
report($e);
}
use Asciisd\Copytrade\Events\SsoAuthenticated;
use Asciisd\Copytrade\Events\SsoLoggedOut;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
Event::listen(SsoAuthenticated::class, function (SsoAuthenticated $event) {
$user = User::query()->firstOrCreate(
['email' => $event->user->email],
['name' => $event->user->name ?? $event->user->email],
);
Auth::login($user);
});
Event::listen(SsoLoggedOut::class, function () {
Auth::logout();
});
use Asciisd\Copytrade\Facades\Copytrade;
if (! Copytrade::sso()->isAuthenticated()) {
return redirect()->route('copytrade.sso.redirect');
}
$token = Copytrade::sso()->token(); // refreshes automatically when expired
$user = Copytrade::sso()->user(); // OpenID Connect claims + profile id
$copytrade = Copytrade::withToken($token->accessToken);
$profile = $copytrade->profiles()->getProfile($user->profileId);
use Asciisd\Copytrade\Facades\Copytrade;
use Illuminate\Http\Request;
public function redirect()
{
return redirect()->away(
Copytrade::sso()->authorizationUrl(intendedUrl: '/dashboard')
);
}
public function callback(Request $request)
{
$session = Copytrade::sso()->handleCallback(
(string) $request->query('code'),
(string) $request->query('state'),
);
// $session->token and $session->user
return redirect()->intended('/dashboard');
}
public function logout()
{
return redirect()->away(
Copytrade::sso()->logout(postLogoutRedirectUri: url('/'))
);
}