This is the code that i am looping through. The string status is set to the new set of screen names each time through the loop. I am currently just trying to do 25 at a time.
status = status.Substring(0, status.Length - 1);
//The next step is to generate an encrypted oAuth signature which Twitter will use to validate the request. To do this, all of the request data is concatenated into a particular format as follows.
var baseFormat = "count=25&oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
// "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
var baseString = string.Format(baseFormat,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
Uri.EscapeDataString(status)
);
baseString = string.Concat("POST&", Uri.EscapeDataString(resource_url),
"&", Uri.EscapeDataString(baseString));
//Using this base string, we then encrypt the data using a composite of the secret keys and the HMAC-SHA1 algorithm.
var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),
"&", Uri.EscapeDataString(oauth_token_secret));
string oauth_signature;
using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));
}
//The oAuth signature is then used to generate the Authentication header. This requires concatenating the public keys and the token generated above into the following format.
var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +
"oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +
"oauth_token=\"{4}\", oauth_signature=\"{5}\", " +
"oauth_version=\"{6}\"";
var authHeader = string.Format(headerFormat,
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_version)
);
//We are now ready to send the request, which is the easy part. Note, we must also disable the Expect: 100-Continue header using the ServicePointManager. Without this code, .NET sends the header by default, which is not supported by Twitter.
// var postBody = "screen_name=" + Uri.EscapeDataString(status);
string postBody = "screen_name=" + Uri.EscapeDataString(status);
ServicePointManager.Expect100Continue = false;
resource_url += "?" + postBody + "&count=25";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
request.Headers.Add("Authorization", authHeader);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
var response = (HttpWebResponse)request.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
string objText = reader.ReadToEnd();