Hi there,
My code has not been changed and this worked fine for long time but now users cannot register their accounts (adding it to our system). Here is the method:
public string DoWebRequest(HTTP_Method Method, string URI, string PostData)
{
string webResponseData = string.Empty;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(“http://twitter.com/oauth/authorize”);
webRequest.Method = Method.ToString();
webRequest.ProtocolVersion = HttpVersion.Version10;
webRequest.ServicePoint.Expect100Continue = false;
webRequest.UserAgent = string.Format(CultureInfo.InvariantCulture, “Twitterizer/{0}”, “1.0.0.0”); ;
webRequest.Timeout = 20000;
try
{
//PostDate value is:
//authenticity_token=5cf84dcaa35a5dc24ce6a601443bb256a1d9e761 &oauth_token=rACZqKqB1dIs3Aadf1SyGHRikcS9MLcFET32I2fRp8
//&session%5Busername_or_email%5D=[email address]&session%5Bpassword%5D=[account password]
if (!string.IsNullOrEmpty(PostData))
{
Stream dataStream = null;
if (Method == HTTP_Method.POST)
{
byte[] byteArray = Encoding.UTF8.GetBytes(PostData);
webRequest.ContentType = “application/x-www-form-urlencoded”;
webRequest.ContentLength = byteArray.Length;
dataStream = webRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
dataStream = null;
}
}
webResponseData = GetWebResponse(webRequest);
webRequest = null;
}
catch (Exception ex)
{
_errorLogs = _errorLogs + " # " + ex.Message;
webResponseData = null;
}
return webResponseData;
}
In above code, dataStream doesn’t return anything and therefore, the next statement (dateStream.write()) throw an exception.
Does anyone knows of a recent change that causing this code to break?
Thx,
Ben