Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.