SSS : ASP ile RSS Feed Oluşturmak
Günlerden beri RSS Feed yaratma konusunda çabalıyorum ancak bu konuda başarılı olamadım. Acaba elinizde sayfanızda kullandığınız gibi bir rss feed var mı paylaşabileceğiniz ya da bu konuda yol gösterebileceğiniz?
Aslında bu temel olarak çok basit. Aşağıda ASP ile kendi yazdığım örneği veriyorum. Direk çalışmayacaktır, değişkenler ve recordset' ler değiştirilmiştir. Dolayısıyla mantığı anladıktan sonra modifiye edip kendi versiyonunuzu yazmanız gereklidir.
<%
'Browser in olayi XML olarak algilayabilmesi icin
Response.ContentType="application/xml"
%><?xml version="1.0" encoding="iso-8859-9"?>
<rss version="2.0">
<channel>
<title>Ferruh Mavituna</title>
<link>http://ferruh.mavituna.com</link>
<description>Ferruh Mavituna tarafından yazılan güvenlik, web teknolojileri başta olmak üzere çeşitli konuları kapsayan makaleler ve haberler.</description>
<language>tr</language>
<copyright>Copyright 1997-2003 Ferruh Mavituna</copyright>
<lastBuildDate><%=GetRFC822Date(DbDatex)%></lastBuildDate>
<docs>http://backend.userland.com/rss</docs>
<generator>Ferruh Mavituna ASP - RSS</generator>
<managingEditor>ferruh - mavituna.com</managingEditor>
<webMaster>ferruh - mavituna.com</webMaster>
<ttl>60</ttl>
<image>
<title>Ferruh Mavituna</title>
<url>http://ferruh.mavituna.com/rss/rss.gif</url>
<link>http://ferruh.mavituna.com</link>
</image>
<%
While counter < Paging And Not Rs.EOF
Cstr = Rs("content")
'Fix RSS
Cstr = Replace(Cstr," src=""/"," src=""http://ferruh.mavituna.com/")
Cstr = Replace(Cstr,"<img ","<img alt="""" ")
Cstr=Server.HTMLEncode(Cstr)
XHeader = Server.HTMLEncode(Dbheader)
Response.Write "<item>" & vbNewline &_
"<title>" & RS("header") &"</title>" & vbNewline &_
"<pubDate>" & GetRFC822Date(DbDatex) & "</pubDate>" & vbNewline &_
"<link>http://ferruh.mavituna.com/makale/" & DbPerma & "/</link>" & vbNewline &_
"<description>" & Cstr & "</description>" & vbNewline &_
"</item>"
counter = counter + 1
Rs.MoveNext
Wend
%>
</channel>
</rss> <%
Rs.Close
Set Rs = Nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GetRFC822Date
' Purpose:
' Gets date in the RFC 822 format (with 4-digit year) as required by the RSS
' 2.0 spec.
' Parameters:
' dtmDate - Date to format.
' Returns:
' Formatted date.
' Revisions:
' [[email protected] 2003-11-02] Code written.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetRFC822Date(dtmDate)
' XXX what about daylight savings?
Dim strDate
strDate = Left(WeekdayName(DatePart("w", dtmDate)), 3) & ", " & _
LeadingZero(DatePart("d", dtmDate))
strDate = strDate & _
" " & Left(MonthName(DatePart("m", dtmDate)), 3) & " " & _
DatePart("yyyy", dtmDate) & _
" " & LeadingZero(DatePart("h", dtmDate))
strDate = strDate & ":" & LeadingZero(DatePart("n", dtmDate)) & _
":" & LeadingZero(DatePart("s", dtmDate)) & " GMT"
GetRFC822Date = strDate
' Format: Sun, 02 Nov 2003 13:40:01 GMT
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' LeadingZero
' Purpose:
' Adds a leading zero to single digit numbers.
' Parameters:
' strText - Var to add a zero to, if necessary.
' Returns:
' Original text, with leading zero if required.
' Revisions:
' [[email protected] 2003-11-02] Code written.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function LeadingZero(strText)
If Len(strText) = 1 Then
LeadingZero = "0" & strText
Else
LeadingZero = strText
End If
End Function
%>