1. Go to this page and download the library: Download pvguerra/laravel-trakt 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/ */
use Laravel\Socialite\Facades\Socialite;
public function redirect()
{
return Socialite::driver('trakt')->redirect();
}
// Receiving the callback from the provider after authentication.
public function callback()
{
$socialiteUser = Socialite::driver('trakt')->user();
// Store the token in your database
$user = auth()->user();
$user->trakt_token = $socialiteUser->token;
$user->trakt_id = $socialiteUser->id;
$user->save();
return redirect()->route('dashboard');
}
use Pvguerra\LaravelTrakt\Facades\Trakt;
// Using the facade
Trakt::setToken('your-access-token');
// Now you can make authenticated requests
$history = Trakt::sync()->history();
// Or using dependency injection
use Pvguerra\LaravelTrakt\TraktUser;
$user = auth()->user();
$traktUser = new TraktUser($user->trakt_token);
return $traktUser->collection($user->trakt_id, 'movies');
use Pvguerra\LaravelTrakt\Facades\Trakt;
$movie = Trakt::movie()->get('the-batman-2022');
use Pvguerra\LaravelTrakt\Facades\Trakt;
$popularMovies = Trakt::movie()->popular();
use Pvguerra\LaravelTrakt\Facades\Trakt;
$show = Trakt::show()->get('game-of-thrones');
use Pvguerra\LaravelTrakt\Facades\Trakt;
$trendingShows = Trakt::show()->trending();
use Pvguerra\LaravelTrakt\Facades\Trakt;
$results = Trakt::search()->query('batman', 'movie');
use Pvguerra\LaravelTrakt\Facades\Trakt;
Trakt::setToken('user-access-token');
$profile = Trakt::user()->profile('me');
use Pvguerra\LaravelTrakt\Facades\Trakt;
Trakt::setToken('user-access-token');
$history = Trakt::user()->history('me', 'movies');
use Pvguerra\LaravelTrakt\Facades\Trakt;
$calendar = Trakt::calendar()->myShows();