dolibarr 21.0.0-alpha
DiasporaHandler Class Reference

Class for handling Diaspora API interactions. More...

Public Member Functions

 fetch ($urlAPI, $maxNb=5, $cacheDelay=60, $cacheDir='', $authParams=[])
 Fetch Social Network API to retrieve posts.
 
 normalizeData ($postData)
 Normalize data of retrieved posts.
 
 getPosts ()
 Get the list of retrieved posts.
 

Private Member Functions

 isCookieValid ()
 Check if the provided cookie in params is valid.
 
 getCookieFromParams ()
 Get the cookie value from params, regardless of the exact key name.
 
 formatDate ($dateString)
 Format date for normalize date.
 

Detailed Description

Class for handling Diaspora API interactions.

Definition at line 29 of file diasporahandler.class.php.

Member Function Documentation

◆ fetch()

DiasporaHandler::fetch ( $urlAPI,
$maxNb = 5,
$cacheDelay = 60,
$cacheDir = '',
$authParams = [] )

Fetch Social Network API to retrieve posts.

Parameters
string$urlAPIURL of the Diaspora API.
int$maxNbMaximum number of posts to retrieve (default is 5).
int$cacheDelayNumber of seconds to use cached data (0 to disable caching).
string$cacheDirDirectory to store cached data.
array$authParamsAuthentication parameters including login URL, username, and password.
Returns
bool Status code: False if error, true if success.

Definition at line 79 of file diasporahandler.class.php.

References dol_filemtime(), dol_hash(), dol_is_file(), dol_mkdir(), dol_now(), getCookieFromParams(), getURLContent(), isCookieValid(), and normalizeData().

◆ formatDate()

DiasporaHandler::formatDate ( $dateString)
private

Format date for normalize date.

Parameters
string$dateStringDate in string format.
Returns
string Formatted date.

Definition at line 173 of file diasporahandler.class.php.

References dol_print_date().

Referenced by normalizeData().

◆ getCookieFromParams()

DiasporaHandler::getCookieFromParams ( )
private

Get the cookie value from params, regardless of the exact key name.

Returns
string|null The cookie string if found, null otherwise.

Definition at line 59 of file diasporahandler.class.php.

Referenced by fetch(), and isCookieValid().

◆ getPosts()

DiasporaHandler::getPosts ( )

Get the list of retrieved posts.

Returns
array List of posts.

Definition at line 184 of file diasporahandler.class.php.

◆ isCookieValid()

DiasporaHandler::isCookieValid ( )
private

Check if the provided cookie in params is valid.

Returns
bool True if a valid cookie is found in params, false otherwise.

Definition at line 50 of file diasporahandler.class.php.

References getCookieFromParams().

Referenced by fetch().

◆ normalizeData()

DiasporaHandler::normalizeData ( $postData)

Normalize data of retrieved posts.

Parameters
array$postDataData of a single post.
Returns
array Normalized post data.

Definition at line 152 of file diasporahandler.class.php.

References formatDate().

Referenced by fetch().


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