megawubs / trakt-api-wrapper

A Object Oriented PHP wrapper for the trakt api
34 stars 19 forks source link

How to use summary ? #19

Closed ghost closed 8 years ago

ghost commented 8 years ago

pls can you help me with this

$trakt = $this->trakt->movies->withImages()->withFull()->summary($token, $movieId);

i get this error

Argument 1 passed to Wubs\Trakt\Api\Movies::summary() must be an instance of League\OAuth2\Client\Token\AccessToken, string given

i have readed the readme but i dont understand how i can do this in a controller

megawubs commented 8 years ago

@DeeJaVu You need to pass it an instance of AccessToken instead of a string.

megawubs commented 8 years ago
<?php
use Wubs\Trakt\Auth\Token;

$token = Token::create(
           $accessToken,
           $type,
           $expires
            $refresh,
            $scope
        );

That's how the AccessToken is created. All these values are given back from Trakt when you get the access token for the first time. You should store them somewhere and every time you need an access token crate it from these values.

Does this help? I'll document the access token a bit more in the documentation. I hope to have it finished by the end of this week.

megawubs commented 8 years ago

I just updated the documentation.

ghost commented 8 years ago

Thank you for letting me know :+1:

ghost commented 8 years ago

i have one problem in my config/trakt.php i have this

return [
"client_id" => '59a5d****',
"client_secret" =>    '62295b1****',
"redirect_uri" => 'http://localhost.dev',
];

the client_id and client_secret are working but the the redirect_uri not as you can see in the image below

so when i go try to authorize like this

// http://localhost.dev/authorize

Route::get('authorize', function (Trakt $trakt) {
//this wil redirect you to the trakt website and, after authorization by the user, trakt will redirect back.
$trakt->auth->authorize();
});

the trakt website says "The redirect uri included is not valid."

2015-09-30 16-33-26 ref - google chrome

megawubs commented 8 years ago

@DeeJaVu Did you register the redirect url with your trakt.tv API App?

ghost commented 8 years ago

FIXED just looked in

vendor\wubs\trakt\src\Wubs\Trakt\Providers\Laravel\TraktApiServiceProvider.php

public function register()
{
    $this->app->singleton(
        TraktProvider::class,
        function ($app) {
            return new TraktProvider(
                config("trakt.client_id"),
                config('trakt.client_secret'),
                config('trakt.trakt_redirect_uri')
            );
        }
    );

    $this->app->bind('trakt', Trakt::class);
}

so i changed config/trakt.php

redirect_uri to trakt_redirect_uri and now its working

ghost commented 8 years ago

its working perfect now :+1:

2015-09-30 17-06-22 ref - google chrome