Search stream by location doesn't work

Oct 14, 2013 at 3:58 PM
problem:
I am trying to filter a twitter stream in a certain area defined by coördinates. This works, but only if the area is big enough (continent wide). If I try a smaller area (as big as a city), it doesn't work anymore.

error:
The remote server returned an error: (406) Not Acceptable.

code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Streaminvi;
using TweetinCore.Interfaces;
using TweetinCore.Interfaces.StreamInvi;
using TweetinCore.Interfaces.TwitterToken;
using Tweetinvi;
using Tweetinvi.Model;
using TwitterToken;

namespace twitter_test
{
public partial class Form1 : Form
{
    private const string userKey = "...";
    private const string userSecret = "...";
    private const string consumerKey = "...";
    private const string consumerSecret = "...";

    public Form1()
    {
        InitializeComponent();
        IToken token = new Token(userKey, userSecret, consumerKey, consumerSecret);

        StreamFilterLocationExample(token);

    }

    private static void StreamFilterLocationExample(IToken token)
    {
        var topLeft = new Coordinates(51.378638, 2.394161);
        var bottomRight = new Coordinates(50.774682, 6.173458);

        var stream = new FilteredStream();
        stream.AddLocation(topLeft, bottomRight);

        int max = 0;
        Action<ITweet> tweetReceived = t =>
        {
            if (max<15)
            {
                Console.WriteLine(t.Text);
                max++;
            }
            else
            {
                stream.StopStream();
            }
        };

        stream.StartStream(token, tweetReceived);

    }
}
}
Oct 14, 2013 at 4:14 PM
Hi Charlotte,

I will check this this evening and give you an answer.

Regards,
Linvi
Oct 14, 2013 at 4:29 PM
Hi Linvi,

Thanks for the fast reply. I was looking through the other topics and you thought you fixed the problem in your latest 0.8.3.1 but apparently the problem is still there.

Regards
Oct 14, 2013 at 10:52 PM
Hello CharlotteK,

Would you please verify your credentials as well as your version.
Tweetinvi 0.8.3.0 had an issue concerning the 406 exception but I tried your code with the 0.8.3.1 and everything worked perfectly for me on Windows 7 and Windows 8.1.

If your credentials are correct you can send me a sample of your project so that I can figure out what is going wrong.

Sincerely,
Linvi
Oct 29, 2013 at 12:44 PM
For developers coming to this post.

Charlotte had 2 issues :
  • 406 Exception : A first issue related with a bug in Tweetinvi. Based on her computer Culture the double were transformed into string differently than what Twitter was expecting. This bug has now been solved.
  • 401 Exception : The time on the computer being incorrectly set cause twitter webservice to reject the request and send a 401 Exception. Updating the time on the computer to the current time and time zone solved the issue.
Hope this might help some of you :)

Linvi
Marked as answer by linvi on 10/29/2013 at 4:44 AM