Wednesday, February 08, 2006
Tuesday, January 10, 2006
Using Feedburner Awareness API to Get Total Subscribers
In this blog entry, I show you how to use Feedburner's Awareness API in conjunction with ASP to publish the number of subscribers on your web site. I try to make this as easy as possible without making it too technical. The fact that I have done 97% of the code for you makes it easy enough.
I have already given you most of the code below and you simply need to change three lines to fit your own feedburner account and web site. For those of you who do not know what an API is, it stands for Application Programming Interface and is a set of preprogrammed open source code that you can readily use and modify at will to fit the needs of your web site.
This code uses the DOM (Document Object Model) to parse the XML provided to you by Feedburner. Your web server will need to be enabled with ASP. Check with your web hosting company if they provide ASP to you. The DOM is an API itself which allows you to step through lines of HTML or XML. All tags in XML DOM are referred to as nodes. The DOM uses a family scenario to move between nodes (parents, childNodes, and siblings) which you will soon find out.
Ok, enough of the intro. Now, let's get into the main part of this blog entry.
Look at this web address:
http://api.feedburner.com/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/FEEDBURNERACCOUNT&dates=2005-12-18,2005-12-31
...where FEEDBURNERACCOUNT is your feedburner feed name. You could simply put a link on your web site to this address and everybody who visits your web site can see it. However, the raw XML is not very pretty to your web site visitors and all the days will be broken down. You simply want the total and not the dates broken down and that is what the ASP code will do for you.
If you put this address into your web browser, you will get all of your circulation and hit data for your account from December 18th to December 31, 2005.
The data will show up as raw XML. Now, from this point on, you need to use ASP and the DOM to extract data from that XML. My code below simply goes through every number found between the quotation marks for "circulation" and adds them up. You obviously end up with a total that the ASP will display right on your web site for you.
I am not going to go through every line of the ASP code below, but only the 3 lines which you need to change. Everything else in the code that I have provided for you can simply be copied and pasted verbatim (except for the 3 modifications) right into your text file.
First of all, the line mydoc.load is the line in the ASP that loads an XML file. Simply replace FEEDBURNERACCOUNT with your Feedburner feed name. The ASP will load the XML from your Feedburner feed.
Secondly, replace the date in the date=2005-12-18 part of the mydoc.load line with the first date your feed went live. In this example, I use 2005-12-18 because my feed went live on December 18, 2005. The format must be YYYY-MM-DD. So for example, if your feed started on January 1, 2006, you need to modify this section of the ASP to date=2006-01-01.
The Awareness API's GetFeedData command also requires an end date in the date range, which will always be yesterday's date. In the ASP, I have set up a variable called APIDate which will always calculate the end date dynamically day after day. So, you never need to adjust the ASP to this value. APIDate will automatically handle that for you.
Lastly, you need to change the const StartingNumber=1000 line to whatever starting number you want your subscription to start at. This will add that number to your actual circulation. If you do not wish to increase this number, then set it to 0 (zero).
COPY THE FOLLOWING CODE BETWEEN THE <% and %>
<%
' FEEDBURNER GETFEEDDATA AwAPI
Dim APIDate, rsp, TotalCirculation, feed, entry
APIDate = Year(date) & "-" & Month(date) & "-" & Day(date)-1
Dim mydoc
Set mydoc=Server.CreateObject("MSXML2.DOMDocument.3.0")
mydoc.async=false
mydoc.setProperty "ServerHTTPRequest",true
mydoc.load("http://api.feedburner.com/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/FEEDBURNERACCOUNT&dates=2005-12-18," & APIDate)
const StartingNumber=1000
Set rsp=mydoc.documentElement
TotalCirculation = 0
For Each feed In rsp.childNodes
If feed.nodeName<>"#comment" Then
For Each entry In feed.childNodes
TotalCirculation = TotalCirculation + entry.attributes.getNamedItem("circulation").text
Next
End if
Next
response.write "" & FormatNumber(TotalCirculation + StartingNumber,0,0,0) & " subscribers!
"
%>
If you are interested in publishing hits as plain text without using the Feedburner Feedcount chicklet, which is a graphic, you can replace the line above entry.attributes.getNamedItem("circulation").text
with entry.attributes.getNamedItem("hits").text.
That is all there is to it. I have provided the most of the ASP code for you and if you have ASP on your web hosting account, then it will work. I am working on a PHP version of this and for those of you who have PHP, I will add this blog entry in the near future.
This Blog is written by Bruce Chambers of Hot Web Ideas, a back end database development firm who has written and marketed proprietary software for online auction web sites, non-commercial blogs, virtual stock exchange web sites, messageboards, web page editors, ecommerce shopping cart systems, online dating web sites and more. Their web site is at http://www.hotwebideas.com and www.WebDesignBilling.com, a web site offering online invoicing and bookkeeping solutions specially for web designers and companies in the web development industry. Hot Web Ideas also writes business plans for web designers and graphic artists to get funding from investors.
Monday, January 02, 2006
Show 3 - Search Engine Strategies - January 2, 2006
Saturday, December 31, 2005
Show #2 is now available and better than ever! Highlights:
- What the Heck Do We Use XML For?
- GET vs POST- What to use in HTML Forms
- Search Engine Meta Tags Are Useless!
- What Web Sites Looked Like In 1996...
We have come so far in our technology for building web sites that it seems people have forgotten what web sites looked like when we didn't have all the bells and whistles. Listen to this podcast for a stroll back at what web sites looked like back then. Does anybody use the HTML BLINK tag anymore? Download the show directly at http://hotwebideas.podlot.net/show2d.mp3
Show #1 Highlights
- CSS Padding Issues
- Firefox vs Internet Explorer and how they both handle CSS
- The 5 Things That Web Site Owners WANT in their web sites
You can download this podcast directly at http://hotwebideas.podlot.net/091005.mp3
Wednesday, December 07, 2005
What is XML used for?
It's interesting when web designers go the classic argument about web design creation tools. Is it Dreamweaver, Frontpage, or just plain typing HTML into a text editor? Most web designers use Dreamweaver or Frontpage, because they did not want to learn HTML.
Hmm. Is HTML too hard to learn? The "notepadders" would disagree, but either way you look at it, HTML is always, and has always been the end result in a web browser, whether it was created with Frontpage or Dreamweaver or typed into a text editor, or rendered dynamically by ASP, PHP, or some other scripting language. I presonally like HTML in a text editor and therefore, you can call me a notepadder.
What's ironic is that HTML is very easy to learn since it requires absolutely no computer programming whatsoever. It is a "formatting" language, not a programming language. I think somehow, when people here the term computer language, then immediately think of programming. With HTML, that is not the case and it just makes learning it that much easier,
Now, XML is another language all with its own purpose, and in my opinion, it is the easiest computer language to learn on the planet. It really is. In fact, XML is so easy that when you ask most web designers, nobody knows what to use it for. That's the focus of this article.
XML has hundreds of uses. Let's get right into some of them. My favorite use for XML is great for some of you web designers out there who have your own company and clients or if you work as a web designer for another company.
Most of our clients want us to make changes to a web site yesterday. We really do not have the time to give them what want in real time. Most web designers ask their clients to wait at least a week or to give the change a week in advance. What if I told you that you could teach your client to use XML tags that YOU make up, save the file, and BOOM, the web page is changed? Yup, you guessed it. All you need to do is make up some XML tags, and use a technology called SAX (Simple API for XML) or another language called XSL (XML Stylesheet Language) both of which can turn that XML into HTML. Through these technologies, your client can instantly change the web site him/herself using a very simple XML interface that you create. Trust me, folks, this really works.
Since XML allows you to create your own tags, you pretty much invent the language that your client uses. Make it easy for your client to type in the changes. Maybe use the following XML "nodes" (XML's terminology similar to the HTML tag) :
- publish date
- title of the page
- the content
You simply create an XSL file to convert your boss's changes to HTML and then you no longer have to make the changes. The changes are typed in by your client or boss and the web page content changes instantly.
In XML Uses Part 2, I will show you how to harness XML's power with XSL to make a web page editor, which is what I did with one of my clients. For right now, suffice it to say, that XML can help you relax, put the responsibility on your client, and at the same time, offer your client a solution to make changes to the site in real time.
Some of you out there may argue why a client would have to make changes. Afterall, you are the web design. Right? Keep in mind, that most web designers have full time jobs and cannot make changes ASAP. So, give this benefit to your client and you will soon find, that your job as teh web designer will get easy.
Web Designer News is a blog publication of Bruce C of Hot Web Ideas, at www.hotwebideas.com.