Solved

RSS Feed with password...

Posted on 2007-12-04
14
455 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CDO.Message not able to send attachement 5 40
innerHTML 7 40
Executing a script on a timer online 5 32
calculate days away 11 23
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 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