Hi @kurrik,
I am using the following article for my oauth, http://www.codeproject.com/Articles/247336/Twitter-OAuth-authentication-using-Net.
I have confirmed that the oauth I am sending is good as I am able to call https://api.twitter.com/1.1/lists/statuses.json and get data returned.
I am still unable to successfully call the streaming API https://stream.twitter.com/1.1/statuses/filter.json.
Here is a copy of my code, I have rejigged the code which works for lists.
public void Stream()
{
//OAuth stuff
var oauth_consumer_key = “consumer key goes here”;
var oauth_consumer_secret = “secret goes here”;
var oauth_token = "access token goes here";
var oauth_token_secret = "secret token goes here";
var oauth_version = "1.0";
var oauth_signature_method = "HMAC-SHA1";
var oauth_nonce = Convert.ToBase64String(
new System.Text.ASCIIEncoding().GetBytes(
DateTime.Now.Ticks.ToString()));
var timeSpan = DateTime.UtcNow
- new DateTime(1970, 1, 1, 0, 0, 0, 0,
DateTimeKind.Utc);
var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
var slug = "libraries-and-news-sites";
var owner_screen_name = "deskfeed";
//var resource_url = "https://api.twitter.com/1.1/lists/statuses.json";
var resource_url = "https://stream.twitter.com/1.1/statuses/filter.json";
//these MUST be in alphabetical order!!!
var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&follow={6}&track={7}";
var baseString = string.Format(baseFormat,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
Uri.EscapeDataString("216299334,15735744"),
Uri.EscapeDataString("stephenfry")
);
baseString = string.Concat("POST&", Uri.EscapeDataString(resource_url),
"&", Uri.EscapeDataString(baseString));
var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),
"&", Uri.EscapeDataString(oauth_token_secret));
string oauth_signature;
using (System.Security.Cryptography.HMACSHA1 hasher = new System.Security.Cryptography.HMACSHA1(System.Text.ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(baseString)));
}
var headerFormat = "OAuth oauth_consumer_key=\"{0}\", oauth_nonce=\"{1}\", oauth_signature=\"{2}\", oauth_signature_method=\"{3}\", oauth_timestamp=\"{4}\", oauth_token=\"{5}\", oauth_version=\"{6}\"";
var authHeader = string.Format(headerFormat,
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_version)
);
ServicePointManager.Expect100Continue = false;
// Actual Twitter request
var getBody = "?follow=216299334,15735744&track=stephenfry";
resource_url += getBody;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
request.Headers.Add("Authorization", authHeader);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
WebResponse response = request.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());
while (!streamReader.EndOfStream)
{
string post = streamReader.ReadLine();
}
}
Note I have tried this with both a GET and a POST, same error.
Any input greatly appreciated.