dolibarr 21.0.0-alpha
|
Class for handler Reddit. More...
Public Member Functions | |
__construct (array $authParams) | |
Constructor to initialize RedditHandler. | |
fetch ($urlAPI, $maxNb=5, $cacheDelay=60, $cacheDir='', $authParams=[]) | |
Fetch Reddit API to retrieve posts. | |
normalizeData ($postData) | |
Normalize the data fetched from the Reddit API. | |
getPosts () | |
Get the list of retrieved posts. | |
getAuthUrl () | |
Get url for authenticate with Reddit. | |
Private Member Functions | |
authenticate () | |
Authenticate with Reddit to get an access token. | |
formatDate ($dateString) | |
Format date for normalize date. | |
Class for handler Reddit.
Definition at line 30 of file reddithandler.class.php.
RedditHandler::__construct | ( | array | $authParams | ) |
Constructor to initialize RedditHandler.
array | $authParams | Array containing 'client_id', 'client_secret', 'username', and 'password'. |
Definition at line 82 of file reddithandler.class.php.
|
private |
Authenticate with Reddit to get an access token.
Definition at line 96 of file reddithandler.class.php.
References getAuthUrl(), and getURLContent().
Referenced by fetch().
RedditHandler::fetch | ( | $urlAPI, | |
$maxNb = 5, | |||
$cacheDelay = 60, | |||
$cacheDir = '', | |||
$authParams = [] ) |
Fetch Reddit API to retrieve posts.
string | $urlAPI | URL of the Reddit API to retrieve posts. |
int | $maxNb | Maximum number of posts to retrieve (default is 5). |
int | $cacheDelay | Number of seconds to use cached data (0 to disable caching). |
string | $cacheDir | Directory to store cached data. |
array | $authParams | Authentication parameters (not used in this context). |
Definition at line 139 of file reddithandler.class.php.
References authenticate(), dol_filemtime(), dol_hash(), dol_is_file(), dol_mkdir(), dol_now(), getURLContent(), and normalizeData().
|
private |
Format date for normalize date.
string | int | $dateString | Date in string format or timestamp. |
Definition at line 230 of file reddithandler.class.php.
References dol_print_date().
Referenced by normalizeData().
RedditHandler::getAuthUrl | ( | ) |
Get url for authenticate with Reddit.
Definition at line 250 of file reddithandler.class.php.
Referenced by authenticate().
RedditHandler::getPosts | ( | ) |
Get the list of retrieved posts.
Definition at line 241 of file reddithandler.class.php.
RedditHandler::normalizeData | ( | $postData | ) |
Normalize the data fetched from the Reddit API.
array | $postData | Data of a single post. |
Definition at line 210 of file reddithandler.class.php.
References formatDate().
Referenced by fetch().