I came across a post in comp.lang.php that I posted 3 years ago as response to this question:
I think the response does not get old therefor I'll rewrite it here with some modifications:
You have to read RFC977 that explains the NTTP protocol. This will help you to understand not only how to get the list of all news groups from news server, but also many other commands.
In the RFC977 one can read:
That was 3 years old script :-)
I am trying to write a PHP script that will download a list of all the newsgroups on a news server and put them into a MySQL database
...
If someone can point me in the right direction to download the group list using PHP, I think I can figure out how to write it to a database.
I think the response does not get old therefor I'll rewrite it here with some modifications:
You have to read RFC977 that explains the NTTP protocol. This will help you to understand not only how to get the list of all news groups from news server, but also many other commands.
In the RFC977 one can read:
LISTAnd here is a script that connects to a news server and gets the list of news groups:
Returns a list of valid newsgroups and associated information.
Each newsgroup is sent as a line of text in the following format:
group last first p
where "group" is the name of the newsgroup, "last" is the number of
the last known article currently in that newsgroup, "first"
is the number of the first article currently in the newsgroup,
and "p" is either 'y' or 'n' indicating whether posting to this
newsgroup is allowed ('y') or prohibited ('n').
$nntp_server = "news.nntpserver.com"; // set your server here
$nntp_port = 119; // do not change this unless you know what you do.
$time_out = 30; // timeout in seconds
$fp = fsockopen($nntp_server, $nntp_port, $errno, $errstr, $time_out);
if (!$fp) {
echo "$errstr ($errno)";
} else {
fputs($fp, "LIST\r\n");
while (!feof($fp)) {
// read one line from the socket
$buffer = fgets($fp,256);
// $buffer will contain something like
// this "alt.comp.lang.php 00000515 00000926 y"
/*
do what you want to do with the buffer here
*/
}
fclose ($fp);
}
That was 3 years old script :-)