Category Archives: Software

Simple Webservice Echo Test

While troubleshooting some PHP Curl issues, I found and used http://respondto.it/ (and later http://requestb.in/) which allows you to create a dummy webservice endpoint which reveals the full request made to it by your code.

An even simpler use case would be a webservice that simply returned data about the request directly to the calling application. I just created such a simple echo webservice on my scooterlabs.com domain.

Update 2012-03-23: Added XML response example as well (scooterlabs.com/echo.xml).

Plain text example

$ curl http://scooterlabs.com/echo
Array
(
[method] => GET
[headers] => Array
(
[User-Agent] => curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
[Host] => scooterlabs.com
[Accept] => */*
)
[request] => Array
(
[foo] => bar
)
[client_ip] => 68.125.160.82
[time_utc] => 2012-01-08T21:33:28+0000
[info] => Echo service from Scooterlabs (http://www.scooterlabs.com)
)

JSON example

$ curl --silent curl http://scooterlabs.com/echo.json?foo=bar | json_xs
{
"info" : "Echo service from Scooterlabs (http://www.scooterlabs.com)",
"request" : {
"foo" : "bar"
},
"headers" : {
"User-Agent" : "curl/7.21.3 (i386-portbld-freebsd7.3) libcurl/7.21.3 OpenSSL/1.0.0e zlib/1.2.3 libidn/1.22",
"Accept" : "*/*",
"Host" : "scooterlabs.com"
},
"client_ip" : "66.39.158.129",
"time_utc" : "2012-01-08T22:07:54+0000",
"method" : "GET"
}

XML example

$ curl --silent http://scooterlabs.com/echo.xml?foo=bar | xml_pp
<?xml version="1.0"?>
<echo>
<method>GET
<headers>
<User-Agent>curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
<Host>scooterlabs.com
<Accept>*/*
</headers>
<request>
<foo>bar
</request>
<client_ip>68.122.10.221
<time_utc>2012-03-24T17:05:49+0000
<info>Echo service from Scooterlabs (http://www.scooterlabs.com)
</echo>

Source

Source code is up on Github: https://github.com/bcantoni/echotest. If anyone has any comments or feedback, let me know here or on Github.

“Read it Later” Apps

For a side project I’m working on, I want to support several different “read it later” type applications. Looking for apps that have both mobile support and APIs, it looks like the most popular options are Instapaper, Read It Later, and Readability.

All of these accomplish a similar task: bookmark a web page for later reading, and formatting it for easier reading. Mobile support is usually included, either for reading articles bookmarked earlier, or marking new ones to read on a desktop at a later time.

Here’s a quick summary of each service:

Instapaper

  • Free service with an optional subscription for $1/month
  • Desktop web browsing
  • Mobile: iPhone/iPad mobile app ($4.99), 3rd-party compatible apps for other mobile platforms
  • API: Simple API (username/password), or Full API (xAuth flavor of OAuth)

Read it Later

  • Desktop: Firefox extension, bookmarklets for others
  • Mobile: Android (pro $0.99), iPhone (free, or pro $2.99)
  • API: Yes, username/password

Readability

  • Subscription service at $5/month (70% of which goes to authors & publishers); $5 is minimum, can do more
  • Desktop web browsing: Yes, also Firefox extension
  • Read Now in browser free, Read Later & Mobile for subscribers only
  • Mobile: Web apps (Android, Blackberry), iPhone/iPad: web now, integration with Instapaper app coming soon
  • API: OAuth

I’ve just started playing with each of these apps and their APIs and will hopefully post more feedback on each.

Fiddler Web Debugging Proxy With Any Browser

Fiddler is an extremely useful tool for debugging any web traffic on Windows environments. From their website:

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and “fiddle” with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

I originally used Fiddler back the early days with Internet Explorer, but have recently picked it up again for use with several different browsers. Although some browsers have more native capabilities now (like Firefox with FireBug), using Fiddler consistently makes it a bit easier to concentrate on the problem at hand rather than the tool itself. Fiddler can also handle and decode HTTPS traffic now.

Setting up Fiddler with different browsers is pretty straightforward:

  • Internet Explorer: No changes needed; when Fiddler is running it will automatically pick up all IE traffic
  • Google Chrome: Same as IE (automatic)
  • Apple Safari: Same as IE (automatic)
  • Opera: Same as IE (automatic), but may need to start Fiddler before Opera
  • Firefox: Change network options to use the HTTP proxy at address 127.0.0.1, port 8888; also see the Fiddler Firefox addon
  • Curl: Curl from the command line is very useful when testing webservices; to route through Fiddler, just include the proxy option like --proxy 127.0.0.1:8888
  • Other Apps: See the Configuring Clients help page for any other application which lets you configure a proxy
  • Mac/Linux: For cases where you need to debug on a different platform, you can still route traffic through Fiddler on a Windows system; after starting Fiddler, set up the application on Mac/Linux to use the proxy at windowshost:8888

For more background and “how-to” guides to get started with Fiddler, check out the Fiddler help page.

Exploring GeoMaker and Yahoo! Placemaker

This week I was motivated to play with some of Yahoo’s Geo tools after hearing a talk by Christian Heilmann regarding the same.

One tool in particular is his Geomaker application which “creates microformats and maps from geographical information embedded in texts”. GeoMaker feeds your provided text into Yahoo’s Placemaker service which will identify any geo locations referenced. Geomaker then massages this data into a Yahoo map widget which can be placed on any web page such as a blog entry.

Geomaker accepts either a block of test, a web page, or an RSS feed. The RSS feed option is a great way to quickly visualize to locations being referenced. For example, the following is a map of recent items from the Yahoo! World News RSS feed:


To stress test Placemaker and see how accurate it is, I dropped in the lyrics for Johnny Cash’s rendition of “I’ve Been Everywhere“. Results? It identified 70 place references and missed 22. The detector seems to be less accurate when given place names like this in a list. It does better when places are used in context, like the news articles above.

Here is the resulting map for “I’ve Been Everywhere” (minus the outlying countries Argentina and Costa Rica):