Download the PHP package wubs/trakt without Composer

On this page you can find all versions of the php package wubs/trakt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package trakt

Notice: This package is abandoned by its maintainer. Please fork and continue from there.

Trakt-api-wrapper version 2

This is the Trakt API wrapper for their new API (version 2).

Installation

In your composer.json file add:"wubs/trakt": "~2.0" and run composer install

The goal

The goal of this wrapper is to make communicating with the Trakt api easier. It aims to be easy, readable and usable in many cases. Designed as a composer package it can be easy installed inside a lager application.

Laravel usage

To use the wrapper inside Laravel, you only have to add Wubs\Trakt\Providers\Laravel\TraktApiServiceProvider::class to the providers array in your config/app.php file. When you've done this, use the \Wubs\Trakt\Trakt class as a type hint to inject it into routes or methods. See here an example:

Non Laravel Usage

If you don't use Laravel, you have to do a bit more to get it working.

Instantiating the Trakt API Wrapper

The API Wrapper needs one dependency. The Wubs\Trakt\Auth class, that in turn depends on Wubs\Trakt\Provider\TraktProvider The TraktProvider holds your client id, secret and your redirect url. To make an Auth object:

With this, you can create the Trakt class.

If you want to mock http request, you can give Trakt a second argument that must implement GuzzleHttp\ClientInterface. When you don't pass one, the real implementation is used to send requests to Trakt.

Once you've created the Trakt object, you should register it inside your IoC container, so you only have to write the code that instantiates the Trakt class once.

OAuth

To get your OAuth token, do the following after creating the Trakt object.

When you created the Auth object, you specified a redirect url. This is the url Trakt is going to redirect the user to, with an code you can use to obtain an access token.

The moment you call $trakt->auth->authorize(); the user will be directed to the authorization page of trakt.tv. After giving your application access to their account, Trakt redirects to the provided url, with a code. This code can than be used to obtain the access token. This can be done like so: $trakt->auth->token($code);

But, when you don’t have a website running yet, you can’t specify a return url. To get the code displayed on the trakt site, you need to tell Trakt that you want to redirect to them self and display the code you need to obtain an access token. You can do this by providing the following string as redirect url: urn:ietf:wg:oauth:2.0:oob. This is only necessary when you have no local dev machine running.

So, lets say your client id is 12345678 and you client secret is secret01 and we you a local dev machine with the host nametrakt.dev. Now, you can set trakt.dev/trakt/auth as our redirect url.

With this you can create a route from witch you do the following. Lets say it's your index route.

When you now go through the OAuth flow, you'll get your token (an instance of League\OAuth2\Client\Token\AccessToken) dumped out on the screen. Store the values from the token somewhere so you can recreate it later when the user needs it. You can do this by using $trakt->auth->createToken() and pass the required parameters $token, $type,$expires, $refresh and $scope. This wil return an instance of League\OAuth2\Client\Token\AccessToken which you can pass to methods that (optionally )require an token.

Using the api wrapper

Now that you have the access token, you can use it to retrieve user-specific data from trakt.tv with the Trakt class.

Pagination and Extended info

To utilise the extended info and pagination features, you have to set the page or extended info level before calling the endpoint. Here is an example:

Extended info goes along the same way:

You can also combine all of this:

The response will now be the second page of the movies/collected endpoint, with all images and all data limited to 20 items per page.

Feel free to contact me or help development :)


All versions of trakt with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.7
illuminate/support Version ~5.2
nesbot/carbon Version ~1
guzzlehttp/guzzle Version ~5
league/oauth2-client Version ~0.8
league/url Version ^3.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wubs/trakt contains the following files

Loading the files please wait ....