That's a lot of code, but it's easier to debug this kind of issues if you show the request to Twitter.
Tom PS: You should switch to oAuth! On Aug 8, 2:28 am, marketingmaniac <[email protected]> wrote: > i use to have this app that suddenly doesn't work anymore,, it use to > work perfectly and now ,, hmm,, > any help would be appreciated,, > > here is the code that update my users profile written in vb 2008/10 > that worked flawlessly > > 'THE BUTTON I MADE TO INITIATE THE SUB CALLED UPLOADPROFILEIMAGE > Private Sub Button37_Click_1(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button37.Click > > Dim photo As Byte() > photo = IO.File.ReadAllBytes("Me.jpg") > UploadProfileImage(photo, username:=("AnaisAlice20"), > pwd:=("pass99")) > > End Sub > > 'THE SUB WHICH THE BUTTON CALLED > > Public Shared Sub UploadProfileImage(ByVal photo As Byte(), ByVal > username As String, ByVal pwd As String) > 'photo is just a byte array of the image data > > 'Dim photo As Byte() > photo = IO.File.ReadAllBytes("c:\me.jpg") > Dim request As HttpWebRequest = > DirectCast(HttpWebRequest.Create("http://twitter.com/account/ > update_profile_image.xml"), HttpWebRequest) > System.Net.ServicePointManager.Expect100Continue = False > request.PreAuthenticate = True > request.AllowWriteStreamBuffering = True > > Dim boundary As String = System.Guid.NewGuid().ToString() > > request.Credentials = New NetworkCredential(username, pwd) > request.ContentType = String.Format("multipart/form- > data;boundary={0}", boundary) > request.Method = "POST" > > ' Build Contents for Post > Dim header As String = "--" & boundary > Dim footer As String = "--" & boundary & "--" > > Dim contents As New StringBuilder() > > ' Image > contents.AppendLine(header) > contents.AppendLine(String.Format("Content-Disposition:form- > data); name=""image""); filename=""{0}""", "twitterProfilePhoto.jpg")) > contents.AppendLine("Content-Type: image/jpeg") > contents.AppendLine() > > contents.AppendLine(System.Text.Encoding.GetEncoding("iso-8859-1").GetString(photo)) > > ' Footer > contents.AppendLine(footer) > > ' Data that is sent with the post > Dim bytes As Byte() = > Encoding.GetEncoding("iso-8859-1").GetBytes(contents.ToString()) > > request.ContentLength = bytes.Length > > Using requestStream As Stream = request.GetRequestStream() > requestStream.Write(bytes, 0, bytes.Length) > requestStream.Flush() > requestStream.Close() > > ' Using response As WebResponse = request.GetResponse() > 'Using reader As New > StreamReader(response.GetResponseStream()) > 'Dim s As String = reader.ReadToEnd() > 'End Using > 'End Using > End Using > End Sub
