Creating and using the client

Tumblr# offers a fully featured client in the TumblrClient class. Creating and using the client is very simple:

namespace Sample
    using DontPanic.TumblrSharp;
    using DontPanic.TumblrSharp.Client;
    using DontPanic.TumblrSharp.OAuth;
    using System.Threading.Tasks;
    public class ApiTest
        private const string consumerKey = "<your consumer key here>";
        private const string consumerSecret = "<your consumer secret here>";

        //!! replace with the access token you got from the OAuth flow
        private Token accessToken = null; 

        public async Task GetBlogInfoAsync()
            //instantiate the client factory
            var factory = new TumblrClientFactory();

            //create the client; TumblrClient implements IDisposable (to dispose
            //of the internal HttpClient)
            using (var client = factory.Create<TumblrClient>(consumerKey, consumerSecret, accessToken))
                //gets the info for a blog; we can either pass the short blog name or
                //the fully qualified blog name (<blog name>
                var blogInfo = await client.GetBlogInfoAsync("thegetty");

Last edited Aug 26, 2013 at 4:25 AM by turboronin, version 1