rvdv/nntp

通过网络新闻传输协议(NNTP)与服务器通信的客户端。

v0.9.2 2017-07-03 08:22 UTC

This package is auto-updated.

Last update: 2024-08-29 03:37:24 UTC


README

通过网络新闻传输协议(NNTP)与服务器通信的客户端。

Latest Stable Version Build Status Scrutinizer Code Quality Code Coverage StyleCI

安装

推荐通过 composer 安装库。

composer require rvdv/nntp:^0.9.0

什么是NNTP?

NNTP指定了一个使用可靠流(如TCP)服务器-客户端模型进行新闻文章分发、查询、检索和发布的协议。NNTP设计得如此,以至于新闻文章只需存储在一个(可能是中央)主机上,而连接到LAN的其他主机上的订阅者可以通过到新闻主机的流连接来阅读新闻文章。

-- RFC 摘要 (来源)

使用方法

以下是一个从 news.php.net 服务器的 php.doc 获取100篇文章的示例

<?php

use Rvdv\Nntp\Connection\Connection;
use Rvdv\Nntp\Client;

$connection = new Connection('news.php.net', 119);
$client = new Client($connection);

$client->connect();

$overviewFormat = $client->overviewFormat();
$group = $client->group('php.doc');
$articles = $client->xover($group['first'], $group['first'] + 100, $overviewFormat);

// Process the articles further...

$client->disconnect();

测试

要运行测试套件,您需要通过composer安装依赖项,然后运行PHPUnit。

$ composer install
$ php vendor/bin/phpunit

许可证

MIT © Robin van der Vleuten