The rss aa module client is the program which polls remote nodes for new items on a regular basis.
The rss aa module client must perform the following tasks:
The rss aa module client is implemented in a new file xmlclient.php3.
The program is expected to run on a regular basis. As a rule of thumb, we expect this interval to be 15 minutes. Because of the fact that the php scripts must be run through the http server, we need to implement the same mechanism as described in the APC Action Applications: E-Mail Subscription Service Specification, chapter 5, section 5.1 and 5.2 ( email-spec-5.html). The task described there is to run a program daily. the same mechanism should be used to run a program every 15 minutes.
The XML parser should be put into an include file
(name probably include/xmlparse.php3. It is used at two spots,
from the rss aa module client specified in this chapter and from the
administrative interface to establish a new incoming feed.
When a request has been made to a rss aa module server, the response is expected to be an xml document. PHP's xml functions are able to parse this result. The PHP xml functions are documented in the PHP 4 manual.
Using the PHP xml functions, a rss aa module parser function is created. Its name
is apcrss_parse. The function takes a string containing the xml
data to be parsed as an argument. It returns an array containing the
result.
The parser function uses at least the PHP functions xml_parser_create, xml_set_element_handler, xml_set_character_data_handler, xml_parse and xml_parser_free.
The return value is an array containing all information that was in the xml data. The actual data structure within this array is not yet specified.
In cases of xml syntax errors, return the error message from the xml parser.
In a new include file include/xml_fetch.php3, a function
xml_fetch to
fetch an xml data file through http is created. This function is used
by the rss aa module client described in this chapter as well as by the
administrative interface.
The function takes these arguments:
The url to which the connection is to be made.
Array containing the parameters that are to be posted with the http request.
The functions returns the received data in a string. On error, the function returns an empty string or, if available, an error message in the string which does not start with a '<' character.
The function
On execution, the script selects all incoming feeds from table external_feeds . The query must join
The program then loops through all feeds. All the following tasks are done for each feed respectively.
For each feed,
constant string ORG_NAME
string from field nodes.password
string from filed external_feeds.user_id
string from field external_feeds.remote_slice_id
numeric value from field
external_feeds.txxxxx
list of category ids which are selected (ef_categories.target_category_id is not empty). The list is composed by appending all category ids together, separated by a white space.
ef_categories.target_category_id to
the id of the local slice's default category so the feed will now include the
new categories. ef_categories.approved is set to 0.externally_fed to the remote node name and put the item into
the correct bin according to
ef_categories
.approved.
If more than one text format is contained in the items's text, select html
if is is there, or plain text. Ignore other formats.