|ASPRSS --> Becoming a directory: Creating your form|
|If you haven't yet read the overview, you should do so now.|
This page describes in detail the steps you need to follow before you can accept RSS article submissions.
Create a submission form for RSS submissions
What exactly will be submitted?
RSS data is XML, but you don't have to deal with that. The source code that we supply will convert the RSS into individual resources and pass them to you one at a time. All you have to do is process the data just as you would from a regular submission form.
However, if you're not an experienced web developer fluent in HTML and a server-side environment like Active Server Pages we should point out that you will need to do some server-side programming to process the data submitted to your form.
How do I create the form?
We provide all the source code you need to support your RSS submission form, but you will need to modify it to work with your site. We show you how. All the code is contained in this zip file. Download that first.
The source code you will use comprises just two files: RSSform_xx and RSSdir_xx, although the zip file contains versions for all of the supported languages and platforms. The xx will depend on the language of your choice:
vbs.asp - Active Server Pages written in VBScript
The languages below are not currently supported, but will be soon. Can you help?
cs.aspx - Active Server Pages.NET written in C# (c-sharp)
What changes do I need to make?
Obviously, depending on which language you choose the sample code will be different, so we won't step you through line-by-line. However, every version has certain things in common which we document here.
Firstly, every version consists of two files - only one of which, RSSform, you have to modify to suit your site. The other file, RSSdir, contains the code that does the hard work for you. The intention is that any updates that we make to this file will only require you to copy the new file to your server.
It is important that some parts of your form remain "standard". You can change the look and feel of the page, but you cannot edit or delete the form inputs provided. They will be used for automatic submissions from ASPRSS. We'll point out exactly what must not change as we walk through the code.
The sample code in RSSform starts by initializing some variables. nResources and nDuplicates are used to count the number of submitted resources and those that were discarded because they already exist in your database. They are completely optional, and were just added to give some feedback to the user - you can remove them if desired. sSubmitRSS contains the text shown on the submit button when submitting a URL - again, you can change it to be whatever you wish.
When the form is submitted we test which submit button was pressed by looking at the value of the "action" form item. This is one reason why the submit button text was put into the sSubmitRSS variable. You'll notice that we also test for "ASPRSSAutoSubmit" - this is to allow ASPRSS to automatically submit to your form, so do not remove that!
Depending on the submit button pressed, one of two functions in the RSSdir SSI (Server Side Include) will be called: ProcessRSSurl or ProcessRSSdata. If for some reason you wish to change the names of the relevant form inputs to something other than "URL" and "XML" you can do so.
Both functions return False if the parsing of the RSS source failed, so I set the bSubmitted variable to this value causing the form to display.
As soon as the functions are called the data is processed. The results of the processing are passed back to you by calling some functions which we will get to in a moment. For now we'll continue walking through RSSform code sequentially...
As we've seen, bSubmitted will only be set when the page has been submitted successfully. If the form has not been submitted yet, or something went wrong with the submission the form will be displayed.
The look and feel of the entire page can be changed as necessary. The sample code shows an ASPRSS banner with a link back to a page on ASPRSS, but you can remove all this.
We do recommend that you provide a link page to "http://ASPRSS.com/Refer.asp?Directory=123" somewhere on the page though - this page is customized to publicize your site alone. Remember to replace the 123 with your sites ID, which was given to you when you registered. For alternative images to use for the link, see the support ASPRSS page.
As mentioned earlier, the results from processing the RSS data are passed back to you by calling some pre-defined functions in this RSSform page. The first, ProcessError, is shown above. This function is called when an error occurs in the data, usually because the MSXML3 component fails to parse it. The provided code simply displays the error message, but in common with all these functions you can do whatever you wish.
ProcessNewRSS is called once per RSS source. It may seem that this should only be called once, but there is a circumstance when this isn't true - RSS data can include a link to other RSS sources (and the RSSdir code will follow those links).
As an example, ASP Alliance may have an RSS file that contains links to all the alliance members' RSS data. Submitting that RSS to this form will automatically submit all the resources from all members' sites.
ProcessPublisher is called whenever a new publisher is found in the RSS source - usually only once per RSS source. So if ProcessNewRSS gets called, ProcessPublisher is not far behind. We're guessing that you'll probably want to store this data in variables for use later when processing individual resources.
Descriptions of the parameters you are sent are shown below:
The last function, ProcessResource is called for each resource present in the RSS. It is likely that this function is where you will gather the publisher data and the resource data together and process it just as you would your normal submission form.
Descriptions of the parameters you are sent are shown below:
Congratulations - if you've followed these instructions you can now accept RSS submissions! Be sure to become a member (it's free) so that we can show you in our database of RSS supporters, and link to your form. You'll appear on the Directories page, and will start getting automatic submissions from ASPRSS subscribers.
If you wondering about the last function in RSSform, DisplayElement, that is just included for demonstration and testing purposes while you are working on the form. You can remove this when it is no longer needed.