Reading Articles
Now that we have the article number of the last article, it is easy to read the last ten articles. RFC977 says that the ARTICLE command can use either the article number or its message ID.
It should be noted 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 different, 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; bouclen";
echo "+----------------------+n";
echo "$articlen";
}
$boucle++;
}
?>
We read the last ten articles from this newsgroup on the server. You can also use the HEAD command to read the header information of the article, or the BODY command to read the article content.
Close the connection
Finally, close the socket by calling the fclose() function and end the conversation with the NNTP server.
www.php.net/manual/function.fclose.php
Conclusion
In the above, we saw how to open, use and close a socket: connect to an NNTP server and retrieve some articles. Publishing an article using the POST command is not much more complicated.
The next step is to write a WEB-based newsgroup client.
It is also very easy to store these articles and index them using a search engine (such as http://www.htdig.org). In this way, you have a web-based program for searching newsgroups.
An example of such a program can be obtained at http://www.phpindex.com/ng/.
http://www.bkjia.com/PHPjc/315316.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/315316.html