LINQ to Twitter v2.1.09 Released

Posted by Joe Mayo on Geeks with Blogs See other posts from Geeks with Blogs or by Joe Mayo
Published on Tue, 15 Oct 2013 02:37:19 GMT Indexed on 2013/10/17 21:57 UTC
Read the original article Hit count: 249

Filed under:

Originally posted on: http://geekswithblogs.net/WinAZ/archive/2013/10/15/linq-to-twitter-v2.1.09-released.aspx

Today, I released LINQ to Twitter v2.1.09. Here are important new changes.

Bug Fixes

This is primarily a bug fix release. Most notably, there were authentication problems in WinRT apps. This is now fixed.

New Features

One new feature is the addition of ApplicationOnlyAuthentication for WinRT. It is fully async.  Here’s how it works:

            var auth = new WinRtApplicationOnlyAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = "",
                    ConsumerSecret = ""
                }
            };

            if (auth == null || !auth.IsAuthorized)
            {
                await auth.AuthorizeAsync();
            }

            var twitterCtx = new TwitterContext(auth);

            (from search in twitterCtx.Search
             where search.Type == SearchType.Search &&
                   search.Query == SearchTextBox.Text
             select search)
            .MaterializedAsyncCallback(
                async response =>
                    await Dispatcher.RunAsync(
                        CoreDispatcherPriority.Normal,
                        async () =>
                        {
                            Search searchResponse = response.State.Single();
                            string message =
                                string.Format(
                                    "Search returned {0} statuses",
                                    searchResponse.Statuses.Count);

                            await new MessageDialog(message, "Search Complete").ShowAsync();
                        }));

It’s called the WinRtApplicationOnlyAuthorizer. You only need two tokens, ConsumerKey and ConsumerSecret, which come from your Twitter API application settings page.

Note: You need a Twitter Application, which you can create at https://dev.twitter.com/.

The MaterializedAsyncCallback materializes your query and handles the response. I put everything together in a lambda for demonstration purposes, but you can always replace the callback with a handler of type Action<TwitterAsyncResponse<IEnumerable<T>>>, where T is Search for this example.

On the Horizon

The next version of LINQ to Twitter is in development. I discussed it at LINQ to Twitter Async. This isn’t complete, but you can download the source code at the LINQ to Twitter site on CodePlex. I’ve competed all the spikes for what I thought would be the hard parts and now have prototypes of queries and commands working. This would be a good time to provide feedback if there are features in the current version that you think could be improved. The current driving forces for the next version will be async and PCL.

 

@JoeMayo

© Geeks with Blogs or respective owner