class DiasporaHandler (View source)

Class for handling Diaspora API interactions

Properties

string $error

Methods

bool
fetch(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '', array<string, 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}
normalizeData(array<string, mixed> $postData)

Normalize data of retrieved 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.

Details

bool fetch(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '', array<string, string> $authParams = [])

Fetch Social Network API to retrieve posts.

Parameters

string $urlAPI

URL of the Diaspora 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<string, string> $authParams

Authentication parameters including login URL, username, and password.

Return Value

bool

Status code: False if error, true if success.

array{}|array{id: string, content: string, created_at: string, url: string, author_name: string, author_avatar: string} normalizeData(array<string, mixed> $postData)

Normalize data of retrieved posts.

Parameters

array<string, mixed> $postData

Data of a single post.

Return Value

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

Normalized post data.

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