Geeks With Blogs

News
Joe Mayo

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>>, 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

Posted on Tuesday, October 15, 2013 9:37 AM LINQ to Twitter | Back to top

Copyright © Joe Mayo | Powered by: GeeksWithBlogs.net