1

I am using swhitley's Twitter Stream Client to download tweets via Twitter Streaming API with username and password. It was using https://stream.twitter.com/1.1/statuses/filter.json.

I modified the code to add OAuth, but I am getting a 400 error. Can anyone pls provide me code or direct me to an opensource project. Or just give me some tips on how to fix the issue.

qbektrix
  • 85
  • 2
  • 9
  • I did this yesterday, is this any help? http://stackoverflow.com/questions/17067996/authenticate-and-request-a-users-timeline-with-twitter-api-1-1-oauth There is a link to the GitHub project with a console app inside. – hutchonoid Jun 13 '13 at 12:33
  • @hutchonoid Thank you for the comment. But your app is using REST API, while I am trying to use the Streaming API. Your code is not working for me. Thank you. – qbektrix Jun 16 '13 at 05:55
  • No probs, I thought it might work in a similar way. If I get time I will try and get it working with the streaming api and post an answer. – hutchonoid Jun 17 '13 at 09:19

1 Answers1

2

If you are having some troubles with your API you can try using Tweetinvi

The API has been developed by myself and another developer in the goal of using the Streaming API.

It is pretty easy to use and you can find examples in the solution (Examplinvi).

Basically, you just have to define a method that will be called foreach of the Tweet received from the API. We have been able to process 3.5 millions tweets a day with this API (storing in MySQL Database).

// Creating the stream and specifying the delegate
SimpleStream myStream = new SimpleStream("https://stream.twitter.com/1.1/statuses/sample.json");
// Create the credentials
IToken token = new Token("userKey", "userSecret", "consumerKey", "consumerSecret");
// Starting the stream by specifying credentials thanks to the Token
myStream.StartStream(token, x => Console.WriteLine(x.Text));

If you need any help, feel free to ask me.

user2465083
  • 595
  • 3
  • 12
  • Looks like TweetInvi would do what we need, but it just doesn't work. The sample code you provide leads me to a null reference exception in UrlEncode. – MikeB Jun 29 '13 at 13:14
  • Would you please provide me more information concerning your code. Did you provide your own Token information? – user2465083 Jul 01 '13 at 11:06
  • 1
    Hello Mike. Please download the latest version. What you have been experiencing might be related with the fact that the default streaming URL was using Twitter 1.0 API. I've update the default URL. Also if you want to change the stream URL (https://dev.twitter.com/docs/streaming-apis/streams/public), you can update the StreamUrl by specifically setting the StreamUrl property. myStream.StreamUrl = "https://myStreamUrl"; myStream.StartStream(token); Please let me know if this solves your issue. Sincerely, Linvi – user2465083 Jul 01 '13 at 11:22
  • Indeed, I had to update the URL. After a few more fixes to the source code, we're off to the races. – MikeB Jul 12 '13 at 14:46
  • If you don't provide any code, I cannot help you. As I said the solution has been used on many different projects, from many different servers with different type of account, so I think it is reliable enough. Now I don't quite get where is your issue as I tested the stream from Tweetinvi and everything seems to work. I would be happy to help you, but I need a little more information for that. – user2465083 Jul 13 '13 at 10:42
  • Sorry if I Wasn't clear; the problems were in Tweetinvi, not in my code. – MikeB Jul 15 '13 at 05:58
  • SimpleStream and IToken are undefined, using latest version of tweetiniv??? plz help @user2465083 – John x Dec 20 '14 at 09:43
  • @user2465083 - Can you please share any code samples for implementing TweetInvi in our Web based application (developed using ASP.NERT, C#, Javascript)? I need a solution for any user by clicking a button in our Web App should get one post (say - Welcome) in their Twitter account (after popup of Twitter sign in). – Apparao May 16 '16 at 07:24