Sign in TopomorphRSS Feed

I use an extension for BlogEngine.net to tweet my new posts (you can find it here).
In the tweet there’s a tiny url link. It works great, but can’t be traced. So I’ve made a few alterations to make it work with tr.im:

//<trim>
  //    <status result="OK" code="200" message="tr.im URL Added." /> 
  //    <url>http://tr.im/nNIk</url> 
  //    <reference>zc4N07GTD5moOyXyczypBsZndG8MJP</reference> 
  //    <trimpath>nNIk</trimpath> 
  //</trim>
  private static string TrimURLFromResponse(string response)
  {
      StringReader stringReader = new StringReader(response);
      XmlReader reader = XmlReader.Create(stringReader);

      reader.ReadToFollowing("url");
      string result = reader.ReadElementString();
      return result;
  }

 

string url = String.Format("http://api.tr.im/api/trim_url.xml?url={0}&username={1}&password={2}", itemUrl.ToString(),TrimUsername,TrimPassword);
string trimResponse = client.DownloadString(url);
tinyUrl = TrimURLFromResponse(trimResponse);

some tests with fiddler show and it could/should work, but it cant be tested in the local Visual Studio webserver, so here’s a test: This post will either be deleted (it does not work) or updated (it does work)

Just a minute … 
Yep! indeed it works.

With the snippets above you should be able to figure out the changes. If you need some help or comment, be sure to drop a line!

Comments