dolibarr 21.0.0-alpha
SocialNetworkManager Class Reference

Class to manage Social network posts. More...

Public Member Functions

 __construct ($platform, $authParams=[])
 Constructor.
 
 fetchPosts ($urlAPI, $maxNb=5, $cacheDelay=60, $cacheDir='', $authParams=[])
 Fetch Social Network API to retrieve posts.
 
 getPosts ()
 Get the list of retrieved posts.
 
 getLastFetchDate ()
 Get the last fetch date.
 

Private Member Functions

 initializeHandler ($authParams)
 Initialize the social network needed.
 

Detailed Description

Class to manage Social network posts.

Definition at line 31 of file socialnetworkmanager.class.php.

Constructor & Destructor Documentation

◆ __construct()

SocialNetworkManager::__construct ( $platform,
$authParams = [] )

Constructor.

Parameters
string$platformname of social network
array$authParamsother parameters

Definition at line 64 of file socialnetworkmanager.class.php.

References initializeHandler().

Member Function Documentation

◆ fetchPosts()

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

Fetch Social Network API to retrieve posts.

Parameters
string$urlAPIURL of the Fediverse 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
Returns
bool Status code: false if error, array if success.

Definition at line 95 of file socialnetworkmanager.class.php.

◆ getLastFetchDate()

SocialNetworkManager::getLastFetchDate ( )

Get the last fetch date.

Returns
int Timestamp of the last successful fetch.

Definition at line 118 of file socialnetworkmanager.class.php.

◆ getPosts()

SocialNetworkManager::getPosts ( )

Get the list of retrieved posts.

Returns
array<array{id:string,content:string,created_at:string,url:string,media_url:string}|array{}> List of posts.

Definition at line 108 of file socialnetworkmanager.class.php.

◆ initializeHandler()

SocialNetworkManager::initializeHandler ( $authParams)
private

Initialize the social network needed.

Parameters
array$authParamsother parameters
Returns
void new instance if founded

Definition at line 75 of file socialnetworkmanager.class.php.

References dol_ucfirst().

Referenced by __construct().


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