Hi there,
My VB knowledge is very old and very poor, and my .NET is only
slightly better. Take a look at:
request.PreAuthenticate = True
request.Credentials = new NetworkCredential(UserName, Password)
I could easily be wrong. Take a look at
http://msdn.microsoft.com/en-us/library/system.net.webrequest_members(VS.71).aspx
Thanks;
— Matt Sanford (@mzsanford)
On Dec 2, 6:58 pm, jpdenoyer <[EMAIL PROTECTED]> wrote:
> Does anyone know how to use a VB (VB express 2005) program to access a
> webpage that requires HTTP Basic Authentication for access?
>
> Below is the code I have so far. It obviously does not work because
> there is no authentification info supplied (and I do not know how to
> supply the info).
>
> Public Class Form1
> Const URL As String = "http://twitter.com/statuses/
> friends_timeline.xml?count=1"
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim request As WebRequest = WebRequest.Create(URL)
>
> Dim response As WebResponse = request.GetResponse()
>
> Dim rssStream As Stream = response.GetResponseStream()
>
> Dim rssDoc As XmlDocument = New XmlDocument()
> rssDoc.Load(rssStream)
>
> DisplayNode(rssDoc, 0)
>
> End Sub
>
> Private Sub DisplayNode(ByVal node As XmlNode, ByVal depth As
> Integer)
> ' Define the indent level.
> Dim Indent As New String(" "c, depth * 4)
>
> ' Display the node type.
> TextBox1.Text &= (Indent & node.NodeType.ToString() & _
> ": <" & node.Name & ">")
>
> ' Display the node content, if applicable.
> If node.Value <> String.Empty Then
> Console.WriteLine(Indent & "Value: " & node.Value)
> End If
>
> ' Display all nested nodes.
> Dim Child As XmlNode
> For Each Child In node.ChildNodes
> DisplayNode(Child, depth + 1)
> Next
> End Sub
> End Class