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{username?:string,password?:string,name_app?:string,client_id?:string,client_secret?:string,redirect_uri?:string,access_token?:string}$authParams other 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{username?:string,password?:string,name_app?:string,client_id?:string,client_secret?:string,redirect_uri?:string,access_token?:string}$authParams Authentication 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 126 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,author_name:string,author_avatar?:string}|array{}> Posts fetched from the API

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

◆ initializeHandler()

SocialNetworkManager::initializeHandler ( $authParams)
private

Initialize the social network needed.

Parameters
array{username?:string,password?:string,name_app?:string,client_id?:string,client_secret?:string,redirect_uri?:string,access_token?:string}$authParams other 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: