I'd like to access NNTP servers, groups, and messages through PHP. Is there any existing class you'd recommend? Preferably PHP5 and good OOP.
5 Answers
It's not a class, but must php installs have the php-imap extension compiled in and you can do all you want with straight php calls.
You can see documentation starts here: http://us.php.net/manual/en/book.imap.php
Examples of opening a connection to an NNTP server can be found in the imap_open topic.
Like this:
// To connect to an group on an NNTP server on port 119 on the local server, use:
$nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
OR
// To connect to a nonlocal server without specifying a group:
$server = "{news.servername.com/nntp:119}";
$nntp = imap_open($server,"","",OP_HALFOPEN);
Then you can just request the info that you want:
$headers = imap_headers($nntp);
$threads = imap_thread($nntp);
That's not exactly what you'd asked for, but I hope it helps.

- 456
- 3
- 10
Also not a class, and also not OOP, and also not PHP 5 specific, the code behind http://news.php.net is available here:

- 4,727
- 1
- 29
- 34
I have been using this. http://pear.php.net/manual/en/package.networking.net-nntp.client.php It seems to work very well. I am using Php 5.3 and 5.4

- 11
- 1
To be also a bit self-promoting on this question. I am the maintainer php-nntp (https://github.com/RobinvdVleuten/php-nntp) and tried to be more OOP and future-proof compared to the old PEAR package (http://pear.php.net/package/Net_NNTP/) which is still used in many NZB sites out there.

- 1,462
- 1
- 16
- 18
I know this question was asked a long time ago, but my answer could help others out.
I've been searching for good PHP Classes to access NNTP. Most of them, however, are built on some lower versions of PHP.
The only one I could find that fully supports the most recent PHP version was developed by a Usenet provider (with me as Lead Developer).
You can find it here: https://www.usenetxl.nl/dev/
There is quite some documentation. There is also documentation in the classes themselves.

- 3,260
- 3
- 19
- 26
-
"I've been searching ... The only one I could find ...". Classes are signed `@author Wouter K.` If you're self promoting, say it. Your classes may be good. – Michael Laffargue Mar 23 '12 at 15:32
-
@WouterKonecny: Do you have an updated link for your NNTP class? The link above is 404'd. – cOle2 Nov 17 '14 at 21:53
-
@cOle2 I was supporting it while I was working there. They apparently removed it some time after I left. I suggest looking at the project RobinvdVleuten is referring to, it looks nice as far as I can see. – Wouter Konecny Nov 20 '14 at 10:30