Snuze  0.8.1
snuze\Reddit\AccessToken Class Reference
Inheritance diagram for snuze\Reddit\AccessToken:

Public Member Functions

 __construct (string $username=null)
 
 getExpires ()
 
 getScope ()
 
 getToken ()
 
 getTokenType ()
 
 getUsername ()
 
 isValid ()
 
 fromJson (string $json)
 
 toJson ()
 
- Public Member Functions inherited from snuze\SnuzeObject
 __construct (array $args=null)
 
 _getSnuzeId ()
 
 _getSnuzeClass ()
 
 _ident ()
 

Private Attributes

 $username = null
 
 $token = null
 
 $expires = 0
 
 $scope = null
 
 $tokenType = null
 

Additional Inherited Members

- Protected Member Functions inherited from snuze\SnuzeObject
 debug (string $message, bool $echo=false)
 
 info (string $message, bool $echo=false)
 
 warning (string $message, bool $echo=false)
 
 error (string $message, bool $echo=false)
 
- Protected Attributes inherited from snuze\SnuzeObject
 $_snuzeId = null
 
 $_snuzeClass = null
 

Detailed Description

An AccessToken represents the authentication information needed to interact with many Reddit API endpoints.


This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey shaun.nosp@m.@sha.nosp@m.unc.c.nosp@m.om https://shaunc.com/ Repository: https://github.com/snuze/snuze/ Documentation: https://snuze.shaunc.com/

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Constructor & Destructor Documentation

◆ __construct()

snuze\Reddit\AccessToken::__construct ( string  $username = null)

Constructor.

Parameters
string$usernameThe Reddit username for this access token
Exceptions

Member Function Documentation

◆ fromJson()

snuze\Reddit\AccessToken::fromJson ( string  $json)

Given the raw JSON response to an API request for an access token, populate and return this AccessToken object.

Parameters
string$jsonThe raw JSON response from Reddit's API server
Returns
\snuze\Reddit\AccessToken
Exceptions

Implements snuze\Interfaces\Jsonable.

◆ getExpires()

snuze\Reddit\AccessToken::getExpires ( )

Get the unix epoch timestamp at which this token expires

Returns
int

◆ getScope()

snuze\Reddit\AccessToken::getScope ( )

Get the scope of this token e.g. '*' or 'read'

Returns
string

◆ getToken()

snuze\Reddit\AccessToken::getToken ( )

Return the raw access token string, if one has been set.

Returns
string|null The access token, or null if there isn't one

◆ getTokenType()

snuze\Reddit\AccessToken::getTokenType ( )

Get the type of token e.g. 'bearer'

Returns
string

◆ getUsername()

snuze\Reddit\AccessToken::getUsername ( )

Get the Reddit account username this token was assigned to

Returns
string

◆ isValid()

snuze\Reddit\AccessToken::isValid ( )

Return whether or not this AccessToken object contains an unexpired token.

Returns
bool True if a token exists and isn't expired; otherwise, false

◆ toJson()

snuze\Reddit\AccessToken::toJson ( )

Returns a JSON-formatted string representing this token's properties. Ideally, this should match Reddit's own data structure for returning access tokens from the API. (Reddit doesn't return the username.)

Returns
string

Implements snuze\Interfaces\Jsonable.


The documentation for this class was generated from the following file: