Read articles
Now that we've got the article number of the last article, it's easy to read the last 10 articles. RFC977 says that the article command can use either the article number or its message ID.
Note here that the article number is different from its message ID, because each news server assigns its own article number, so the number of the same article on two different servers is not the same, and the message ID of the article is included in the header information of the article and is unique.
$cfgLimit = 10;
Upload last Articles
$boucle = $last-$cfgLimit;
while ($boucle <= $last) {
Set_time_limit (0);
Fputs ($usenet _handle, "article $bouclen");
$article = "";
$tmp =fgets ($usenet _handle, 4069);
if (substr ($tmp, 0, 3)! = "220") {
echo "+----------------------+n";
echo "Error on article $bouclen";
echo "+----------------------+n";
}
else {
while ($tmp! = ". Rn") {
$tmp = fgets ($usenet _handle, 4096);
$article. = $tmp;
}
echo "+----------------------+n";
echo "Article $bouclen";
echo "+----------------------+n";
echo "$articlen";
}
$boucle + +;
}
?>
We read the last 10 articles from this newsgroup on the server. You can also read the header information of an article by using the Head command, or use the body command to read the contents of the article.
Close connection
Finally, end the dialog with the NNTP server by calling the Fclose () function to close the socket.
Close connection
Fclose ($usenet _handle);
?>
For more information about fclose (), please refer to http://www.php.net/manual/function.fclose.php
Conclusion
In the above, we see how to open, use, and then close a socket: Connect to an NNTP server and retrieve some articles. Using the post command to publish an article is not so complicated.
The next step is to write a web-based newsgroup client.
Storing these articles, using a search engine (such as http://www.htdig.org) to index the article is also very easy. In this way, you have a Web-based search newsgroup program.
An example of such a program can be obtained in http://www.phpindex.com/ng/.
http://www.bkjia.com/PHPjc/315316.html www.bkjia.com true http://www.bkjia.com/PHPjc/315316.html techarticle read the article since we've got the article number of the last article, it's easy to read the last 10 articles. RFC977 said that the article command can use both the article number ...