class FediverseParser (View source)

Class to parse Fediverse files

Properties

DoliDB $db
string $error

Methods

__construct($platform)

Constructor

int
parser(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '')

Parse Fediverse 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|string
getLastFetchDate()

Get the last fetch date.

Details

__construct($platform)

Constructor

@param string $platform name of social network

Parameters

$platform

int parser(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '')

Parse Fediverse 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.

Return Value

int

Status code: <0 if error, >0 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|string getLastFetchDate()

Get the last fetch date.

Return Value

int|string

Timestamp of the last successful fetch.