How to implement Twitter Site Stream ?

May 22, 2014 at 4:53 PM
I have used Tweetinvi for User Streams like a charm :).

Next, I have a requirement where other twitter users authorizes my Twitter application via Oauth. Now I want to listen to the tweets posted by all those users who authorized my app.

How can I do that ?

From Twitter documentation, I could guess that Site Streams is the option which deals with listening to streams of multiple users. But I could not find a way in Tweetinvi to implement that. Provided that, while the stream listener has been started, there will be more users to be added to it as soon they authorize my app.

Regards.
Coordinator
May 26, 2014 at 9:29 PM
I personally requested an access to site streams in order to create the appropriate wrapper but Twitter never replied to me.
As a result I have never been able to implement the site stream in Tweetinvi.

Consequently you'll have to create your own implementation for site stream or give me some credentials so that I do it for you.

Here is how to create you own stream.

Create a class that Inherit from TwitterStream.
In a method called StartStream do the following:
Func<HttpWebRequest> generateWebRequest = delegate
{
    var parameters = "follow=6253282";
    return "https://sitestream.twitter.com/1.1/site.json?" + parameters;
};

Action<string> generateTweetDelegate = json =>
{
    RaiseJsonObjectReceived(json);

    var tweet = _tweetFactory.GenerateTweetFromJson(json);
    if (tweet == null)
    {
        TryInvokeGlobalStreamMessages(json);
        return;
    }
    
    // Do your code logic here to manage other messages from Twitter
};

await _streamResultGenerator.StartStreamAsync(generateTweetDelegate, generateWebRequest);
If you could share an access to the site stream api I would be very grateful.

Kind Regards,
Linvi
May 28, 2014 at 12:03 PM
Hi Linvi,

Thanks a lot for you kind attention.
I am writing an application (http://selfies.ever.camera/) which intents to track Twitter users and post tweets on the behalf of their OAuth credentials.

I am having different issues using Tweetinvi, which I have already posted on the Tweetinvi forum and found answers to some of them.

The last and most important issue for me here is, to make this application STABLE after adding a new track to the filtered stream, and continue listening to and posting back tweets. Because as yet, when ever I STOP/ADD TRACK/RESUME a stream it just stops with unknown error and exits instead of resuming the stream.

Please find the attached code sample with this message, explaining how I am trying to achieve this goal.

Please help me to find the exact error I am making in doing so.

Thanks for all the effort you already have done in Tweetinvi, its looking like the best wrapper around Twitter on the planet.

Regards.


Coordinator
May 28, 2014 at 9:05 PM
Hi,

I am glad you like it. I could not access the code you attached.
Would you please send it to me directly to my contact page?

Regards,
Linvi
May 29, 2014 at 10:17 AM
Please find the attached file Sample.cs.txt.