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 Pvguerra\LaravelTrakt\TraktMovie;
$traktMovie = new TraktMovie();
return $traktMovie->get('the-batman-2022');
use Pvguerra\LaravelTrakt\TraktShow;
$traktShow = new TraktShow();
return $traktShow->popular();
// web.php
Route::get('auth/redirect', [OAuthController::class, 'redirect'])->name('trakt.auth');
Route::get('auth/callback', [OAuthController::class, 'callback'])->name('trakt.callback');
// authController.php
use Laravel\Socialite\Facades\Socialite;
// Redirecting the user to the OAuth provider.
public function redirect()
{
return Socialite::driver('trakt')->redirect();
}
// Receiving the callback from the provider after authentication.
public function callback()
{
$socialiteUser = Socialite::driver('trakt')->user();
//...
}
use Pvguerra\LaravelTrakt\TraktUser;
$user = auth()->user();
$traktUser = new TraktUser($user->token);
return $traktUser->collection($user->trakt_id, 'movies');