Solved

RSS Feed with password...

Posted on 2007-12-04
14
453 Views
Last Modified: 2013-11-18
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
Comment
Question by:kevp75
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 20402617
>> 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
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 20402630
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
 
LVL 28

Expert Comment

by:sybe
ID: 20402658
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
LVL 28

Expert Comment

by:sybe
ID: 20402707
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
 
LVL 25

Author Comment

by:kevp75
ID: 20403841
it is an intranet site that uses Windows Auth.
0
 
LVL 25

Author Comment

by:kevp75
ID: 20403851
@Stilgar.....method did not work.   The site I am using is localhost to pull the feed from our company intranet
0
 
LVL 28

Accepted Solution

by:
sybe earned 250 total points
ID: 20404192
> 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
 
LVL 25

Author Comment

by:kevp75
ID: 20404305
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
 
LVL 25

Author Comment

by:kevp75
ID: 20404633
ok....so...know of any good javascript feed readers?
0
 
LVL 14

Assisted Solution

by:_Stilgar_
_Stilgar_ earned 250 total points
ID: 20404689
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
 
LVL 25

Author Comment

by:kevp75
ID: 20404719
it's a URL http://intranet.oursite.com/rssfeed....

the feed does not display, all I get is a blank page...
0
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 20404899
You sure it doesn't get loaded? debug your code, see if its your code's fault or the feed's

Stilgar.
0
 
LVL 25

Author Comment

by:kevp75
ID: 20405117
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
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 20405210
:)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate report pulling data (links) from three tables 31 66
ASP Focus problem 3 67
JQuery to parse xml string and get element by id 4 47
Obtain data from database .mdb 4 19
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question