keinos/mastodon-streaming-api-listener 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

keinos/mastodon-streaming-api-listener

Composer 安装命令:

composer require keinos/mastodon-streaming-api-listener

包简介

Listens to the server-sent messages of Mastodon Streaming API and returns the events in JSON.

README 文档

README

Simple Mastodon Streaming API Listener

This is a PHP class that listens to the Mastodon Streaming API's server-sent messages.

Install

composer require keinos/mastodon-streaming-api-listener

Usage

<?php

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

$conf = [
    // Your Mastodon server URL
    'url_host' => 'https://qiitadon.com/',
];

$listener = new \KEINOS\MSTDN_TOOLS\Listener\Listener($conf);

/**
 * $listener ............ The iterator.
 *   $event_name ........ Event name. ("update" or "delete")
 *   $data_payload ...... Data of the event in JSON string.
 */
foreach($listener as $event_name => $data_payload) {
    echo 'Event name: ' . $event_name . PHP_EOL;
    echo 'Data: '. PHP_EOL;
    print_r(json_decode($data_payload));
}
<?php

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

// Alias \KEINOS\MSTDN_TOOLS\Listener\Listener as Listener
use KEINOS\MSTDN_TOOLS\Listener\Listener;

$conf = [
    'url_host' => 'https://qiitadon.com/',
    // If the server is in "whitelist-mode" then you'll need an access token.
    'access_token' => 'YOUR_ACCESS_TOKEN',
];

$listener = new Listener($conf);

foreach($listener as $event_name => $data_payload) {
    echo 'Event name: ' . $event_name . PHP_EOL;
    echo 'Data: '. PHP_EOL;
    print_r(json_decode($data_payload));
}
<?php

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

use KEINOS\MSTDN_TOOLS\Listener\Listener;

$conf = [
    'url_host' => 'https://qiitadon.com/',
    // To listen the local time line stream set 'local'. 'public' is the default.
    'type_stream' => 'local',
];

$listener = new Listener($conf);

foreach($listener as $event_name => $data_payload) {
    echo 'Event name: ' . $event_name . PHP_EOL;
    echo 'Data: '. PHP_EOL;
    print_r(json_decode($data_payload));
}

Package Information

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固