this function use to work,, now its doesnt ?  anyone know why?

    Public Shared Function Account_UpdateProfileImage(ByVal username
As String, ByVal password As String, ByVal image As Byte(), ByVal
extension As ImageExtension) As String
        Try
            Dim s As String = String.Empty

            System.Net.ServicePointManager.Expect100Continue = False

            Dim updateRequest As HttpWebRequest =
DirectCast(HttpWebRequest.Create("http://twitter.com/account/
update_profile_image.xml"), HttpWebRequest)
            updateRequest.PreAuthenticate = True
            updateRequest.AllowWriteStreamBuffering = True

            Dim boundary As String = System.Guid.NewGuid().ToString()

            updateRequest.Credentials = New
NetworkCredential(username, password)
            updateRequest.ContentType = [String].Format("multipart/
form-data;boundary={0}", boundary)
            updateRequest.Method = "POST"

            Dim header As String = "--" & boundary
            Dim footer As String = "--" & boundary & "--"

            Dim headers As New StringBuilder()

            headers.AppendLine(header)

            Select Case extension
                Case (ImageExtension.PNG)
                    If True Then
                        headers.AppendLine([String].Format("Content-
Disposition:form-data); name=""image""); filename=""{0}""",
"image.png"))
                        headers.AppendLine("Content-Type: image/png")
                        Exit Select
                    End If
                Case (ImageExtension.GIF)
                    If True Then
                        headers.AppendLine([String].Format("Content-
Disposition:form-data); name=""image""); filename=""{0}""",
"image.gif"))
                        headers.AppendLine("Content-Type: image/gif")
                        Exit Select
                    End If
                Case (ImageExtension.JPEG)
                    If True Then
                        headers.AppendLine([String].Format("Content-
Disposition:form-data); name=""image""); filename=""{0}""",
"image.jpg"))
                        headers.AppendLine("Content-Type: image/jpeg")
                        Exit Select
                    End If
            End Select

            headers.AppendLine()
 
headers.AppendLine(System.Text.Encoding.GetEncoding("iso-8859-1").GetString(image))
            headers.AppendLine(footer)

            Dim contents As Byte() =
Encoding.GetEncoding("iso-8859-1").GetBytes(headers.ToString())

            updateRequest.ContentLength = contents.Length

            Using requestStream As Stream =
updateRequest.GetRequestStream()
                requestStream.Write(contents, 0, contents.Length)
                requestStream.Flush()
                requestStream.Close()


                Using webResponse As WebResponse =
updateRequest.GetResponse()
                    Using responseReader As New
StreamReader(webResponse.GetResponseStream())
                        s = responseReader.ReadToEnd()
                    End Using
                End Using
            End Using
            Return (s)
        Catch ex As Exception
            Return (ex.Message)

        End Try
    End Function

Reply via email to