keinos/mastodon-streaming-api-config

Class that holds configuration info to use KEINOS\MSTDN_TOOLS classes.

1.0.1 2020-07-22 16:56 UTC

This package is auto-updated.

Last update: 2024-10-23 12:36:11 UTC


README

Configuration Settings Class

This PHP class simply holds Mastodon server information from "instance" API method.

Use this class to get the URI of Mastodon Streaming API for receiving messages from server-sent events or WebSocket.

Install

composer require keinos/mastodon-streaming-api-config

Usage

<?php

namespace KEINOS\Sample;

require_once __DIR__ . '/../vendor/autoload.php';

$conf = new \KEINOS\MSTDN_TOOLS\Config\Config([
    'url_host' => 'https://qiitadon.com/', // Your server/instance URL
]);

$info_instance = $conf->getInfoInstance();
$uri_websocket = $conf->getUriStreamingApi();

If the server/instance is in WHITELIST_MODE then you will need an access token to get the server information.

<?php

namespace KEINOS\Sample;

require_once __DIR__ . '/../vendor/autoload.php';

use KEINOS\MSTDN_TOOLS\Config\Config;

$conf = new Config([
    'url_host'     => 'https://qiitadon.com/',
    'access_token' => 'YOUR ACCESS TOKEN HERE',
]);

$info_instance = $conf->getInfoInstance();
$uri_websocket = $conf->getUriStreamingApi();
$access_token  = $cong->getAccessToken();

Package Information