• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

RSS Feed with password...

I have code to read an RSS feed into a page, via classic ASP and MSXML2.Domdocument.

We have an intranet here that is password protected, what I'd like to know is, how can I pass my username/password to my code so I can view this feed locally.  I am using local IIS, and the code follows...
Public Function strGetRSS(strURL, strFeedsToShow)
	    'Let's set our object
	    dim xmlDom, nodeCol, oNode, oChildNode
	    set xmlDom = Server.CreateObject("MSXML2.Domdocument")
		    xmlDOM.async = False
		    'Set our HTTP Request
		    call xmlDom.setProperty("ServerHTTPRequest", true)
		    xmlDom.async = False
		    'Now we load the document
		    call xmlDom.load(strURL)
		    'Check for elements
		    if not xmlDom.documentElement is nothing then
			    set nodeCol = xmlDom.documentElement.selectNodes("channel/item")
				    'Start a count of the articles to display
				    i = 0			  
				    'Start to loop through each article
				    for each oNode in nodeCol
					    'This number sets the number of articles to display
					    if i < strFeedsToShow then
						    Response.Write("<div>" & vbCrLf)
						    'The Link
						    set oChildNode = oNode.selectSingleNode("link")
							    if not oChildNode is nothing then
								    strRSSLink = oChildNode.text
							    end if
						    set oChildNode = nothing
						    'The Title
						    set oChildNode = oNode.selectSingleNode("title")
							    if not oChildNode is nothing then
								    strRSSTitle = Server.HTMLEncode(oChildNode.text)
								    strGetRSS = strGetRSS & "<div class='rssTitle'><a href=""#"" onclick=""loadurl('/golfTipsMagModule2/content.asp?url=" & server.URLEncode(strRSSLink) & "&pt="&Request.QueryString("c")&"&title="&server.URLEncode(strRSSTitle)&"','rssFull');return false;"">" & strRSSTitle & "</a></div>"
							    end if
						    set oChildNode = nothing
						    'Published Date
						    set oChildNode = oNode.selectSingleNode("pubDate")
							    if not oChildNode is nothing then
								    strRSSPubDate = Server.HTMLEncode(oChildNode.text)
								    strGetRSS = strGetRSS & "<div class='rssDate'>" & strRSSPubDate & "</div>" & vbCrLf
							    end if
						    set oChildNode = nothing
						    'The Description
						    set oChildNode = oNode.selectSingleNode("description")
							    if not oChildNode is nothing then
								    strRSSDesc = oChildNode.text
								    strGetRSS = strGetRSS & "<div class='rssDesc'>" & strRSSDesc & "</div>"
							    end if
						    set oChildNode = nothing
						    'Add 1 to the article count number
						    i = i + 1
						    strGetRSS = strGetRSS & "</div>" & vbCrLf
					    end if
				    next
			    set nodeCol = nothing
		    else
			    strGetRSS = strGetRSS & strPANError & vbCrLf
		    end if
	    set xmlDom = nothing
    End Function

Open in new window

0
kevp75
Asked:
kevp75
  • 6
  • 4
  • 3
  • +1
2 Solutions
 
Loganathan NatarajanLAMP DeveloperCommented:
>> how can I pass my username/password to my code

if INTERNET is connected, the code will fetch the feeds results... not sure about your intranet setup to pass the authentication details to access internet..,
0
 
_Stilgar_Commented:
That depands on the password type. Try formatting your URL (that you pass as strURL) as follows:

http://username:password@ip_or_url/folder/file.rss

Stilgar.
0
 
sybeCommented:
You can use the "Microsoft.XMLHTTP" object, and use the same object twice.

First time you submit your username/password to the login script. The object is then logged on (it will have cookies, even a session-cookie). Then use the same object (which is now logged in) to get the code for the RSS. After that you'll have to process the returned RSS into an XML-object, but I guess that is not problematic for you.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
sybeCommented:
I use this function sometimes, but you might want to adapt it for your own purpose
Function LoginAndGetUrl(ByVal sLoginUrl, ByVal sLoginData, ByVal sLoginMethod, ByVal sUrlToGet, ByVal sUrlData, ByVal sGetUrlMethod)
    Dim oXMLHttpRequest
 
    Set oXMLHttpRequest = Server.CreateObject("Microsoft.XMLHTTP")
 
    ' first login in (and get a cookie)
    If LCase(sLoginMethod) = "post" Then
        oXMLHttpRequest.Open "POST", sLoginUrl, False
        oXMLHttpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        oXMLHttpRequest.Send Unescape(sLoginData)
    Else
        oXMLHttpRequest.open "GET", sLoginUrl & "?" & sLoginData, False
        oXMLHttpRequest.send
    End If
 
    ' then - using the same object, get the url
 
    If LCase(sGetUrlMethod) = "post" Then
        oXMLHttpRequest.Open "POST", sUrlToGet, False
        oXMLHttpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        oXMLHttpRequest.Send Unescape(sUrlData)
    Else
        oXMLHttpRequest.open "GET", sUrlToGet & "?" & sUrlData, False
        oXMLHttpRequest.send
    End If
 
    LoginAndGetUrl = oXMLHttpRequest.responseText
    Set oXMLHttpRequest = Nothing
End Function

Open in new window

0
 
kevp75Author Commented:
it is an intranet site that uses Windows Auth.
0
 
kevp75Author Commented:
@Stilgar.....method did not work.   The site I am using is localhost to pull the feed from our company intranet
0
 
sybeCommented:
> it is an intranet site that uses Windows Auth.

You mean integrated authentication (which is I believe IE only)?

You can of course also grab the RSS in the client, with a clientside javascript or vbscript. Because if the browser is logged in automatically, then any client script calls will use that authentication.
0
 
kevp75Author Commented:
I mean windows authentication.  I am grabbing the RSS in the client with serverside vbscript, and though I have added the 2 sites to my trusted sites, I can open the intranet site without logging in now, I cannot get the feed to show
0
 
kevp75Author Commented:
ok....so...know of any good javascript feed readers?
0
 
_Stilgar_Commented:
Well, finding a javascript piece is really easy:

http://momche.net/publish/article.php?page=rssload
http://www.xml.com/pub/a/2006/09/13/rss-and-ajax-a-simple-news-reader.html

but I'm still trying to understand what exactly goes wrong at your end. How is the path you're using looks like - an IP URL like the one I proposed? a file path starting with \\? and what does it mean "I cannot get the feed to show" - what do you get?

Stilgar.
0
 
kevp75Author Commented:
it's a URL http://intranet.oursite.com/rssfeed....

the feed does not display, all I get is a blank page...
0
 
_Stilgar_Commented:
You sure it doesn't get loaded? debug your code, see if its your code's fault or the feed's

Stilgar.
0
 
kevp75Author Commented:
Stilgar....c'mon now.....

it does not load.  I've put in alerts/response.writes on the .xml and strGetRSS and nothing comes up (except the null for the alert)

I'm going to use that first link you posted  (since I already tried it for this feed, and it works.)

The issue is, because the intranet site uses Windows Authentication, I cannot use server-side code to do this.  I have to use client side code (as the browser is already setup to trust the site(s))
0
 
_Stilgar_Commented:
:)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now