kissifrot/php-nntp

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

v0.10.0 2016-10-28 19:32 UTC

This package is auto-updated.

Last update: 2024-08-29 04:53:03 UTC


README

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

Latest Stable Version Build Status Build status Scrutinizer Code Quality Code Coverage Gittip SensioLabsInsight

安装

推荐通过Composer安装库。

{
    "require": {
        "rvdv/nntp": "^0.8"
    }
}

什么是NNTP?

NNTP定义了一个通过可靠流(如TCP)服务器-客户端模型来分发、查询、检索和发布新闻文章的协议。NNTP的设计使得新闻文章只需要存储在一个(可能为中心)主机上,连接到局域网的其他主机上的订阅者可以使用到新闻主机的流连接来阅读新闻文章。

-- 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();

$command = $client->overviewFormat();
$overviewFormat = $command->getResult();

$command = $client->group('php.doc');
$group = $command->getResult();

$command = $client->xover($group['first'], $group['first'] + 100, $overviewFormat);
$articles = $command->getResult();

// Process the articles further...

$client->disconnect();

测试

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

$ composer install
$ php vendor/bin/phpunit

许可证

MIT,见LICENSE