Use sockets: get articles from newsgroups (3) read articles
Since we have obtained the number of the last article, it is easy to read the last 10 articles. In RFC977, the ARTICLE command can use either the ARTICLE number or its message ID.
Note that the article number is different from its message ID, because each news server assigns its own article number, therefore, the numbers of the same article on two different servers are 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 ");
We read the last 10 articles from the newsgroup on the server ,. You can also use the HEAD command to read the header information of an article or the BODY command to read the content of the article.
Close connection
Finally, close the socket by calling the fclose () function to end the conversation with the NNTP server.
// Close connection
Fclose ($ usenet_handle );
?>
For more information about fclose (), see http://www.php.net/manual/function.fclose.php
Conclusion
In the above article, 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 POST articles is not complicated.
The next step is to write a WEB-based newsgroup client.
It is also very easy to index these articles with a search engine, such as a http://www.htdig.org. In this way, you have a web-based newsgroup search program.
An example of such a program can be obtained at http://www.phpindex.com/ng.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.