Tumblr Mangles Developer Relations
Last week I logged on to Tumblr and was confronted with this abomination:

Missing e notice from tumblr. Way to encourage API development, guys.
Needless to say, this is pretty disturbing, and I wonder what Tumblr is thinking by posting this.
Continue reading: Tumblr Mangles Developer Relations »
The Danger Of API Development: Making Something Too Good
On CNET, via slashdot: Lendle, a Web site that had helped facilitate the loaning of ebooks among Kindle users, was effectively destroyed when Amazon shut down Lendle’s access to its Kindle API.
Lendle first reported the news via Twitter: “Amazon has revoked Lendle’s API access. This is why the site is down. It’s sad and unfortunate that Amazon is shutting down lending sites…According to Amazon, Lendle does not ‘serve the principal purpose of driving sales of products and services on the Amazon site.’”
According to Lendle co-founder Jeff Croft, “at least two other Kindle lending services” have been terminated from the API.
The problem with Lendle and its cousins is simple: It was too good at what it did.
Amazon does allow one-time loans of an ebook for up to 14 days, but they expect such trading to be among intimates. Lendle greatly expanded the ability for one person to trade with a complete stranger, and as a result posed a serious threat to potential Kindle edition sales.
After all, if I can’t find someone to lend me an ebook, I probably have to buy it. Put me in big enough a room of Kindle owners, however, and I’m likely to find what I am after for free.
I don’t care to get into copyright, the nature of modern publishing, or the like. I’m far more interested in pointing out the problem with using third-party APIs that this illustrates: If you make something too good, there’s usually nothing stopping the API service from cutting you off and stealing your work.
Continue reading: The Danger Of API Development: Making Something Too Good »
Getting QueryString Values From A Rewritten URL / ASP.NET Routing URL
During today’s similcast of the ASP.NET Firestarter in Atlanta, G. Andrew Duthie discussed .NET 4′s new support for routing — or, what everyone in Web development calls “URL rewriting.” *
Someone online asked, “If I use routing, can I access query string variables using JavaScript?”
The question isn’t as confused as it sounds on the surface. Of course, if one uses routing / URL rewriting, it’s to remove query string variable and make them part of what appears to be a permanent file structure.
In other words, this:
http://www.server.com/path/to/file.aspx?v1=foo&v2=bar
Becomes this:
http://www.server.com/path/to/file/v1/foo/v2/bar/
The questioner really means, is there a way, after rewriting a URL, to extract key->value pairs from it via JavaScript? The answer is yes; rather than using the location.search property, which allows JavaScript to get the querystring parameters of a URL, we use location.pathname to get the part of the URL that follows the domain, and use that to create our key->value pairs.
Continue reading: Getting QueryString Values From A Rewritten URL / ASP.NET Routing URL »
New England GiveCamp 2010: What A Great Experience
The first New England GiveCamp was this weekend at Microsoft’s Northeast Research and Development building in Cambridge, MA, and it was, by far, one of the most rewarding experiences I’ve had in the 15 years I have been professionally coding.
About 100 technical and non-technical volunteers spent the weekend of June 11-13 writing code for charities. Most projects were Web site upgrades — either installing a content management system, or extending that system to do something it didn’t do before, such as collecting very specific data, integrating with a customer relationship management tool, etc.
Other projects were more complex. For example, my project was data normalization and version control.
I was assigned to the Goshen Land Trust, a charity that protects open and green space in Goshen, CT. My team members were Kriss Aho and Pat Tormey, both from the Boston area; and Chris Craig, the president of GLT.
Prior to last weekend, GLT tracked all its customer relationships in Excel spreadsheets. They do their accounting in Quickbooks.
If someone was a volunteer, his name went into the volunteer spreadsheet. If he owned land, his name was in the landowner spreadsheet. If he was a land or money donor, his name went into another spreadsheet. And so on, and so on; this story has been told a thousand times before, we all know it by heart.
And, of course, there were several versions of each of these spreadsheets out there: They were exchanged back and forth via e-mail, meaning no two copies of the same spreadsheet were alike. Again, stop me if you’ve heard this one before.
Finally, donor payments are managed entirely separate from the spreadsheets, via entries into Quickbooks. So there’s a completely different store of around 800 mostly duplicate names in Quickbooks, too, which isn’t easily compared to a spreadsheet of about 2,000 names.
So we had to figure out a way to impose some version control on these sheets; we had to create a master data store, so we could have an authoritative source of customer relationship information; and we had to sync customer information in Quickbooks to match the master data store.
Sounds like fun, I know. It actually was, after it stopped being awful.
Continue reading: New England GiveCamp 2010: What A Great Experience »
Shortening URLs With The bit.ly API Via ASP.NET
After yesterday’s post on using the Twitter API to post status updates on Twitter from an ASP.NET application, a follower of my client suggested using a URL shortening service to link to the articles headlines being posted as tweets.
That was an excellent idea of which I should have thought in the first place. And thanks to the extreme simplicity of the REST-like bit.ly API, shortening URLs is as simple as sending a request URL laced with querystring variables.
So here is a quick and simple ASP.NET subroutine, written in VB.NET, to shorten URLs with the bit.ly API:
Sub BitlyIt(ByVal strUser As String, ByVal strAPIKey As String, ByVal strLongUrl As String)
'This subroutine requires your page to have a label control named lblStatus
'build URL to shorten method resource
Dim strUri As New StringBuilder("http://api.bit.ly/shorten?")
strUri.Append("version=2.0.1")
'we want to get an XML response back from bit.ly, not the default JSON
strUri.Append("&format=xml")
strUri.Append("&longUrl=")
strUri.Append(Server.HtmlEncode(strLongUrl))
strUri.Append("&login=")
strUri.Append(Server.HTMLEncode(strUser))
strUri.Append("&apiKey=")
strUri.Append(Server.HTMLEncode(strAPIKey))
'create request for shorten resource
Dim objRequest As HttpWebRequest = WebRequest.Create(strUri.ToString())
'since we are passing querystring variables, our method is get
objRequest.Method = "GET"
'act as though we are sending a form
objRequest.ContentType = "application/x-www-form-urlencoded"
'don't wait for a 100 Continue HTTP response from bit.ly
objRequest.ServicePoint.Expect100Continue = False
'since we are using get, we need not send a request body; set content-length to 0
objRequest.ContentLength = 0
'we need to capture the XML being sent in response
'read the response into a new XML document
Dim objResponse As WebResponse = objRequest.GetResponse()
Dim objXML As New XmlDocument()
objXML.Load(objResponse.GetResponseStream())
'the response will have three node values we're primarily interested in
'the errorCode node will contain a numeric error code; 0 means success
Dim nErrorCode As XmlNode = objXML.SelectSingleNode("//errorCode")
'if there was an error, the errorMessage node will contain a user-friendly message useful for debugging
Dim nErrorMsg As XmlNode = objXML.SelectSingleNode("//errorMessage")
'if all went well, shortUrl will contain the full short URL created for our link
Dim nShortUrl As XmlNode = objXML.SelectSingleNode("//shortUrl")
'if we didn't get an errorCode value of 0, there was a problem; report the user-friendly message
'on success, report the short URL for our resource
If nErrorCode.InnerText <> "0" Then
lblStatus.Text = "Error returned. Code: " & nErrorCode.InnerText & "; Message: " & nErrorMsg.InnerText
Else
lblStatus.Text = nShortUrl.InnerText
End If
End Sub
Continue reading: Shortening URLs With The bit.ly API Via ASP.NET »

