class SocialNetworkManager (View source)

Class to manage Social network posts

Properties

DoliDB $db
string $error

Methods

__construct($platform, array{username?: string, password?: string, name_app?: string, client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams = [])

Constructor

bool
fetchPosts(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '', array{username?: string, password?: string, name_app?: string, client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams = [])

Fetch Social Network API to retrieve posts.

array<array{id: string, content: string, created_at: string, url: string, author_name: string, author_avatar?: string}|array{}>
getPosts()

Get the list of retrieved posts.

int
getLastFetchDate()

Get the last fetch date.

Details

__construct($platform, array{username?: string, password?: string, name_app?: string, client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams = [])

Constructor

@param string $platform name of social network

Parameters

$platform
array{username?: string, password?: string, name_app?: string, client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams

other parameters

bool fetchPosts(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '', array{username?: string, password?: string, name_app?: string, client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams = [])

Fetch Social Network API to retrieve posts.

Parameters

string $urlAPI

URL of the Fediverse API.

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

Authentication parameters

Return Value

bool

Status code: false if error, array if success.

array<array{id: string, content: string, created_at: string, url: string, author_name: string, author_avatar?: string}|array{}> getPosts()

Get the list of retrieved posts.

Return Value

array<array{id: string, content: string, created_at: string, url: string, author_name: string, author_avatar?: string}|array{}>

Posts fetched from the API

int getLastFetchDate()

Get the last fetch date.

Return Value

int

Timestamp of the last successful fetch.