Overview

Namespaces

  • JohnRivs
    • Wunderlist

Classes

  • JohnRivs\Wunderlist\Wunderlist

Traits

  • JohnRivs\Wunderlist\Authorization
  • JohnRivs\Wunderlist\Avatar
  • JohnRivs\Wunderlist\Comment
  • JohnRivs\Wunderlist\File
  • JohnRivs\Wunderlist\Folder
  • JohnRivs\Wunderlist\Lists
  • JohnRivs\Wunderlist\Note
  • JohnRivs\Wunderlist\Reminder
  • JohnRivs\Wunderlist\Subtask
  • JohnRivs\Wunderlist\Task
  • JohnRivs\Wunderlist\User
  • JohnRivs\Wunderlist\Webhook
  • Overview
  • Namespace
  • Class
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 
<?php namespace JohnRivs\Wunderlist;

use GuzzleHttp\json_decode;

trait Authorization {

    /**
     * The URL where the user will be redirected to
     * in order to authorize your app.
     *
     * @param  string $state A random string that you'll need to store and check later.
     * @param  string $callbackUrl The URL where the user will be sent after authorizing your app.
     * @return string
     */
    public function authUrl($state, $callbackUrl)
    {
        return 'https://www.wunderlist.com/oauth/authorize?client_id=' .
               $this->clientId .
               '&redirect_uri=' .
               $callbackUrl .
               '&state=' .
               $state;
    }

    /**
     * Get the user's access token.
     *
     * @param  string $code A string provided by Wunderlist in the earlier step.
     * @return string
     */
    public function getAuthToken($code)
    {
        return json_decode($this->http->post('https://www.wunderlist.com/oauth/access_token', [
            'body' => [
                'client_id' => $this->clientId,
                'client_secret' => $this->clientSecret,
                'code' => $code
            ],
            'verify' => false
        ])->getBody())['access_token'];
    }

}
API documentation generated by ApiGen