Skip to content

Instantly share code, notes, and snippets.

@troygoode
Created June 26, 2010 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troygoode/454149 to your computer and use it in GitHub Desktop.
Save troygoode/454149 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.IO;
using System.Xml.Linq;
using System.Threading;
namespace TumblrAPI.ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Started...");
TumblrAPI.Authentication.Email = "myemail@notyours.com"; //Console.ReadLine();
TumblrAPI.Authentication.Password = "poopypants"; //Console.ReadLine();
if(TumblrAPI.Authenticaiton.Status != TumblrAPI.AuthenticationStatus.Valid)
throw new UnauthorizedAccessException("Incorrect Tumblr credentials.");
Console.WriteLine("Now make some posts...");
//Get the DasBlog XML files, they are like <entry><title/><content/></entry> and stuff
XNamespace ns = "urn:newtelligence-com:dasblog:runtime:data";
var posts =
from file in DirectoryInfo(@"C:\overheardathome\xml").GetFileSystemInfos("*.dayentry.xml")
orderby file.Name
from entry in XDocument.Load(file.FullName).Root.Descendants(ns + "Entry")
select new TumblrAPI.Post.Text{
Title = (string)entry.Element(ns + "Title"),
Body = (string)entry.Element(ns + "Content")
};
foreach(var post in posts){
Console.WriteLine(" Response from text post: {0}", post.Publish());
Thread.Sleep(500); //Tumblr will API limit me if I bash on them.
}
Console.WriteLine("Done, press any key...");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment