Search sample not working in visual Studio 2008

Sep 28, 2012 at 6:36 PM

The search code example from the documentation (shown below) does not work in my environment. It 's driving me crazy. I am developing on vs2008, .net 3.5. The srch.queryresult is not being recognized by VS, so I think I might have to install something extra. Hope anyone can help! Thanks

 

Code:

var srch =
    (from search in twitterCtx.Search
    where search.Type == SearchType.Search &&
      search.Query == "LINQ to Twitter"
    select search)
    .Single();

Console.WriteLine("\nQuery: {0}\n", srch.QueryResult);
srch.Results.ForEach(entry =>
    Console.WriteLine(
      "ID: {0, -15}, Source: {1}\nContent: {2}\n",
      entry.ID, entry.Source, entry.Text));

Console.WriteLine("\n More Search demos can be downloaded from LINQ to Twitter's on-line samples at http://linqtotwitter.codeplex.com/wikipage?title=LINQ%20to%20Twitter%20Samples&referringTitle=Home");
Coordinator
Sep 28, 2012 at 10:04 PM

Hi,

The latest LINQ to Twitter has been updated to work with Twitter API v1.1 and Search changed.  I still have some documentation and samples to update, which is probably causing some confusion.  The samples in the downloadable code (Source tab) work and are a better reference. Here's a better example:

            var srch =
                (from search in twitterCtx.Search
                 where search.Type == SearchType.Search &&
                       search.Query == "LINQ To Twitter" &&
                       search.PageSize == 4
                 select search)
                .Single();

            Console.WriteLine("\nQuery: {0}\n", srch.SearchMetaData.Query);
            srch.Statuses.ForEach(entry =>
                Console.WriteLine(
                    "ID: {0, -15}, Source: {1}\nContent: {2}\n",
                    entry.ID, entry.Source, entry.Text));

In the past some API's, like Search, didn't require authentication.  However, now everything requires authentication, including Search. Here's my blog post on what changed:

http://geekswithblogs.net/WinAZ/archive/2012/09/21/converting-linq-to-twitter-to-twitter-api-v1.1.aspx

Joe

Oct 9, 2012 at 11:14 AM

Thanks Joe, I now got it working!