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 31 of file reddithandler.class.php.
RedditHandler::__construct | ( | array | $authParams | ) |
Constructor to initialize RedditHandler.
array{client_id?:string,client_secret?:string,username?:string,password?:string,name_app?:string} | $authParams Array containing 'client_id', 'client_secret', 'username', and 'password'. |
Definition at line 83 of file reddithandler.class.php.
|
private |
Authenticate with Reddit to get an access token.
Definition at line 97 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{client_id?:string,client_secret?:string,username?:string,password?:string,name_app?:string} | $authParams Authentication parameters (not used in this context). |
Definition at line 140 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 231 of file reddithandler.class.php.
References dol_print_date().
Referenced by normalizeData().
RedditHandler::getAuthUrl | ( | ) |
Get url for authenticate with Reddit.
Definition at line 251 of file reddithandler.class.php.
Referenced by authenticate().
RedditHandler::getPosts | ( | ) |
Get the list of retrieved posts.
Definition at line 242 of file reddithandler.class.php.
RedditHandler::normalizeData | ( | $postData | ) |
Normalize the data fetched from the Reddit API.
array{id?:string,title?:string,created?:string,permalink?:string,thumbnail?:string} | $postData Data of a single post. |
Definition at line 211 of file reddithandler.class.php.
References formatDate().
Referenced by fetch().