class MastodonHandler (View source)

Class for handler Mastodon

Properties

string $error

Methods

__construct(array{client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams)

Constructor to set the necessary credentials.

false|array{id: string, content: string, created_at: string, url: string, media_url: string}|array{}
fetch(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '', array{client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams = [])

Fetch posts from Mastodon API using the access token.

array{id: string, content: string, created_at: string, url: string, media_url: string}|array{}
normalizeData(array{content?: string, created_at?: string, url?: string, media_attachments?: array<array{url: string}>} $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.

string
getRedirectUri()

Getter for url to redirect

string
getAccessToken()

Getter for access token

string
getClientId()

Getter for client Id

string
getClientSecret()

Getter for secret client

Details

__construct(array{client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams)

Constructor to set the necessary credentials.

Parameters

array{client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams

parameters for authentication

false|array{id: string, content: string, created_at: string, url: string, media_url: string}|array{} fetch(string $urlAPI, int $maxNb = 5, int $cacheDelay = 60, string $cacheDir = '', array{client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams = [])

Fetch posts from Mastodon API using the access token.

Parameters

string $urlAPI

The URL of the API endpoint

int $maxNb

Maximum number of posts to retrieve

int $cacheDelay

Cache delay in seconds

string $cacheDir

Directory for caching

array{client_id?: string, client_secret?: string, redirect_uri?: string, access_token?: string} $authParams

Authentication parameters

Return Value

false|array{id: string, content: string, created_at: string, url: string, media_url: string}|array{}

Array of posts if successful, False otherwise

array{id: string, content: string, created_at: string, url: string, media_url: string}|array{} normalizeData(array{content?: string, created_at?: string, url?: string, media_attachments?: array<array{url: string}>} $postData)

Normalize data of retrieved posts

Parameters

array{content?: string, created_at?: string, url?: string, media_attachments?: array<array{url: string}>} $postData

post retrieved

Return Value

array{id: string, content: string, created_at: string, url: string, media_url: string}|array{}

return array with normalized postData

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

string getRedirectUri()

Getter for url to redirect

Return Value

string url

string getAccessToken()

Getter for access token

Return Value

string token

string getClientId()

Getter for client Id

Return Value

string

client Id

string getClientSecret()

Getter for secret client

Return Value

string

secret client