Thursday, July 29, 2010

Windows Live REST Explorer – Messenger Connect

Roadmap

This post is part of a series of related posts on how to use Windows Live Messenger Connect.

1. (this post) Using Messenger Connect REST Explorer for exploring Windows Live resources.
2. Using the Messenger Connect JavaScript API for listing your contacts.

Overview


Messenger Connect is a new offering from Microsoft that allows you (a developer of a web site) to allow your customers to log into your web site using Windows Live credentials. Your Messenger Connect -enabled web site furthermore, allows users, once they have authenticated and consented, to be able to access their social graph (contacts, activities, etc.) while on your site. For more information see this Windows Live post. It is similar to FaceBook Connect which was discussed previously in this blog here and here. However, Messenger Connect comes to the table with a more mature set of APIs (Windows Live SDK - download here) and more flexibility for different scenarios. In this post we'll deal with the first step in understanding Messenger Connect and that is understanding the data model (technically called the Resource Model) that supports these capabilities. We'll do this using a tool that Windows Live has provided called Windows Live REST Explorer (REX): http://rex.mslivelabs.com/. We will view data from and write data to the Windows Live cloud.

Viewing Resource Data

The Windows Live Resource Model is similar to the Facebook API, but whereas the Facebook API had some public data you could access without having an Application ID (i.e. registering with Facebook). Instead, viewing Windows Live resources using REX requires you to log in to begin seeing any data. Furthermore, with REX you are exploring your own data, not the data of others.

The Windows Live Resource Model defines top level resources such as contacts, profiles, and activities, collections of data entries, and data entries (an individual contact or profile, e.g.). It's not completely intuitive at first glance, but suffice it to say you can get to all of your Windows Live data one way or another. Each top level resource, collection, and entity has a unique URI address. The Windows Live Resource Model is RESTful in that you make requests (via the browser client) and receive responses. Each request is for a specific (REST) resource that is uniquely addressed. So, every piece of your Windows Live data is accessible with a well formed URI and can be accessed provided you have been authenticated.

REX is an interface to explore your Windows Live resources, but it is not how you will typically consume this data from the cloud. Rather, you will likely use the APIs provided by in the Messenger Connect release, like the JavaScript API or the .NET API. For this post we'll concentrate on just the REST explorer, REX, to understand the resources and how they are organized and then in a follow up post deal with accessing resources using APIs.

Let's look closely at REX. The first thing you have to do is choose a Scope and then log in. The idea of a scope is that it indicates what resources you want to access and what you want to do with them (view, update, e.g.). Let's make sure the scope matches the screenshot below. In particular we want to select the ability to update contacts (WL_Activities.Update). WL = Windows Live. Activities = resource. Update = permission desired.

Windows Live REST Explorer 1

After setting the scopes click the Connect button and you should receive the consent dialog shown below.

Windows Live REST Explorer 2

If you click the "What will I share?" link you can review what is going to be shared. It will match the scopes you specified. The real interesting scenario for reviewing what you will share is for a web site that is Messenger Connect-enabled and you, now playing the part of the user, do not know what scopes have been specified and you want to review them before consenting. It’s your chance to refuse sharing your data. But in this scenario here, you are just viewing your own data so you should be okay to consent.

Windows Live REST Explorer 3

After successfully authenticating and providing consent you are at the top level of your resource tree. REX allows you to see resource data in a variety of formats (RSS, ATOM, JSON, or POX). Change it a few times to see the different formats, but for this post we’ll stick with JSON.

Windows Live REST Explorer 4

In all the screenshots in this post the CID is obscured. When you log in your CID will be unique to your Windows Live credentials.

From the REX home page you'll be able to drill down through data going from top level resources to resource collections to data entities. So, for example, if you click through the ContactsLink on the home page you come to the collection page of categories and contacts.

Windows Live REST Explorer 5

Clicking the AllContactsLink, you come to the contacts collection page.

Windows Live REST Explorer 6

Clicking through to any of the SelfLinks of a contact brings you to a contact entity page. You've drilled all the way down to a resource, a contact in this case.

Windows Live REST Explorer 7

Don't forget that if you log into http://home.live.com/ with the same credentials you used for REX you will access the same data, but through the UI. Also, if you captured the URL http://sn1.apis.live.net/V4.1/cid-**YOUR-CID-HERE**/Contacts/AllContacts, closed the browser, reopened and pasted it in the address bar you will receive either nothing or an error The idea is that you can’t access a collection or entity without first authenticating.

Modifying Resource Data
You can also use REX to make changes to your data. Doing it through REX is not the preferred way but it helps you understand the REST commands that are in use behind the JavaScript Library is part of this release. So let's suppose we want to add a new activity using the Windows Live REST Explorer. Note that in REX there is a "Request" tab and a drop down for the action (verb) you want to take (GET, PUT, POST, DELETE, HEAD, OPTIONS). So far we've been just using the "Response" tab and GET requests. To create a new activity we'll use a POST action and fill in the Request tab with the appropriate information. This is all documented fairly well in the MSDN topic REST API Service and Resource Model. Our goal is to make this appear in our Messenger social feed (http://home.live.com):

Windows Live REST Explorer 8

  1. Start at the collection page of MyActivities: http://bay.apis.live.net/V4.1/cid-***YOUR-CID-HERE***/MyActivities
  2. Select POST from the action dropdown
    Click the Request tab and enter data similar to the following to create a new activity marking a favorite:
     
    {"__type": "MarkFavoriteActivity:http://schemas.microsoft.com/ado/2007/08/dataservices",
    "ActivityVerb": "http://activitystrea.ms/schema/1.0/favorite",
    "ApplicationLink": "http://www.travelmarx.net",
    "ActivityObjects": [
    {
    "ActivityObjectType": "http://activitystrea.ms/schema/1.0/*",
    "AlternateLink": "http://travelmarx.blogspot.com",
    "PreviewLink": "http://travelmarx.blogspot.com/thumbnail.jpg",
    "Title": "A blog I follow.",
    "Summary": "About traveling - without moving."
    }
    ]
    }

  3. Note that we have kept the default data presentation of JSON and so we'll enter data in this way as well. For more information on the syntax see http://json.org/.
  4. Click the submit button (the green arrow) and the activity should be created and appear in your Messenger Social feed as shown above.


Windows Live REST Explorer 9

So, there you have it, a quick overview of the Windows Live REST Explorer (REX) that allows you to browse Windows Live resource data.

Monday, July 26, 2010

Amazing and Rare Things: The Art of Natural History in the Age of Discovery

Amazing Rare Things - David Attenborough Book Cover 

The book Amazing Rare Things: The Art of Natural History in the Age of Discovery (2009) is the guide for an exhibition of the same name that took place at the Queen’s Gallery, Buckingham Palace, London March 14 – September 28, 2008. If only I were there! Most of the imagery in the book appears on the related exhibition site

Natural history is the study of plants and animals through observation rather than experimentation. Amazing Rare Things gives you a whistle-stop tour of the development of natural history by focusing on five individuals from the 15th to the 18th century. A short chapter is devoted to each featured individual: Leonardo da Vinci (1452 – 1519), Cassiano dal Pozzo (1588 – 1657), Alexander Marshal (c. 1620 – 1682), Maria Sibylla Merian (1647 – 1717), and Mark Catesby (1682 – 1749). David Attenborough contributes with an introduction to the book as well as comments on illustrations interspersed throughout the volume where he gives insight into what the illustrator must a have been thinking or observed. 

To be honest, this guide/book is probably not the best source to get a good introduction to natural history, but is really designed for those already familiar with this subject or those really into botanical art. This book is all about beautiful imagery, drawings and watercolors, by Leonardo, Marshal, Sibylla Merian, and Catesby, as well as images from the “paper musuem” of the collector dal Pozzo. 

A reoccurring theme throughout the book is that of the cabinet of curiosities which was a collection of objects whose categories and relationships were not well defined. Do we have curiosity cabinets today? I think so, just in a different way. I like to think of this blog or my copious personal notes (as disorganized and scattered as they are) as a humble form of a digital cabinet of curiosities – applicable to me. Anyway, I digress. Cabinets of curiosities were an important step in the evolution of natural history. As key collections came together, drawing objects in the collection followed, and that was then followed by the search for new curiosities to expand the collection to satisfy the collector’s ego, impress his friends, or maybe just for curiosity’s sake. Curiosity cabinets grew from the introduction of new flora and fauna into Europe from a new age of exploration. The influx was exponential and challenged long held beliefs and classification systems. 

Reading Amazing Rare Things I was introduced for the first time to the incredible story of Maria Sibylla Merian. In 1699, age 52, and divorced she journeyed from the Netherlands to Surinam (South America) to study first hand the country’s flora and fauna, and in particular, butterflies and moths. She remained there for several years there and returned to produce her monumental Metamorphsis insectorum Surinamensium published in 1705. 

The story or life that I most closely identified with is that of Alexander Marshal, an English gentleman who worked for 30 years on a florilegium (flower book) purely for his own pleasure and with no thought to publishing. He seemed to live with various well-connected individuals, drawing their gardens. When he died, his tombstone read ‘PROLEM NON RELIQUIT AT PROBITATE ET INGENIO LONGIOR HUIC FACTA EST DATA VITA FUIT’ – translated as ‘He left no issue, but by reason of his integrity and gifts he will live longer than the life which was vouchsafed for him.’

Wednesday, July 14, 2010

Desert Blister Beetle – Lytta magister

The desert blister beetle (Lytta magister)

Travelmarx has gone buggy, or, shall we say beetle-y, lately. Here’s a beetle, the desert blister beetle (Lytta magister), that we saw while hiking on the Eisenhower Mountain Trail (accessible from the Living Desert) in Palm Desert. We saw swarms of blister beetles eating brittlebush (Encelia farinosa) like the one pictured here is doing.

The term “blister” in the common name for the blister beetle comes from the fact that these beetles can emit a poisonous chemical, cantharidin, through what is called reflex bleeding (autohaemorrhaging). As a side note, there is such a thing as a Spanish fly (Lytta vesicatoria) - in the same genus as the blister beetle – which can be used to incite mating in farm animals. Ingested cantharides (from the crushed powder of this beetle) pass through the digestive track and cause irritation in the urethral passage. That doesn’t sound like fun.

Yard Work – Harmonia axyridis

Lady Beetle
The photo above is a ladybug or ladybird in its larval stage which usually goes for about two weeks. This beetle is probably toward the end of the larval stage judging by the color on its back. After the larval stage it pupates and becomes an adult. Since ladybugs/ladybirds are neither a bug nor a bird the preferred name is lady beetle. Lady beetles belong to the family Coccinellidae which is part of the beetle order, Coleoptera (from the Greek koleos “sheath” and pteron “wing” = sheathed wing). We will hazard a guess that this is Harmonia axyridis (Asian lady beetle), the most common lady beetle in North America. It was introduced into North America several times, most recently in the 1980s by the USDA, to control aphids. It is not known whether the axyridis population in North America is from the intentional introduction or accidental introduction or both.

Domestic Help – Salticus scenicus

Zebra spider (salticus scenicus)
This zebra spider (Salticus scenicus) was helping clean around the house the other day and we snapped this photo. Zebra spiders are a type of jumping spider. They do not build a web, but rather move around looking for prey. We were glad to read that jumping spiders are noted for their awareness when being watched by humans and often turn their body toward the observer. We were starting to get a little wigged out there. More on jumping spiders. The genus name we are guessing derives from the Latin verb root “to jump”. In Italian, the verb for jump is saltare.

Thursday, July 8, 2010

Ape Cave Lava Tube

Mount St. Helens from Lahar Viewpoint
How does a 1.5 mile walk through a lava tube in pitch black sound? Well, you can take that walk as well as explore more lava-related features on the south side of Mount St. Helens (an active volcano that last erupted in 1980) where there are three National Volcanic Monument attractions to explore: Ape Cave, Lahar Viewpoint, and Lava Canyon. Ape Cave is the lava tube.

Ape Cave is a lava tube formed during an eruption of Mount St. Helens 1,900 years ago. The lava tube is 2.25 miles long and drops a few hundred feet along its length. The main entrance to the tube is at 0.75 miles up from the lower end of the tube. From the main entrance you can follow the upper cave for 1.5 miles or the lower cave for 0.75 miles. We walked up through the upper cave and came out at the upper entrance. During the hike there were a couple of difficult spots (like an 8 foot high lava fall) that were tricky to get up but doable if you are in reasonable shape. After exiting at the upper entrance you can follow an easy above-ground trail back to the main entrance. Plan ahead and bring the appropriate gear for exploring the cave such as the right clothes and flashlights. You can rent lamps at Apes' Headquarters in the parking lot for Ape Cave, but check to make sure it (the headquarters) is open on the day you plan to visit.

It makes sense if you are in the area to also take in the Lahar Viewpoint and Lava Canyon which are just a few minutes’ drive further. From Ape Cave you first reach Lahar Viewpoint where there are designated spots where you can pull over and read interpretive signs and gaze at Mount St. Helens. The lahar (a volcanic mudslide) on the southern and eastern flanks of Mount St. Helens is one of the many landscape changers of the May 18, 1980 eruption, though the most serious destruction was to the north of St. Helens. (A short video on the eruption.)

Continuing from the Lahar Viewpoint on you reach Lava Canyon. There is one main trail, 184, and several loop variations. The main trail follows the Muddy River downstream and is not particularly dangerous but is definitely not for those who don’t like obstacles (40 ft ladder down a cliff) or when the trail narrows and has moderate drop offs. The cool suspension bridge is not too far from the start of trail and you could walk down one side of the river, go over the bridge, and come back on the other side for a short, easy walk. In Lava Canyon you can see 25 million year old lava (tan and purpled colored) and 2,500 year old lava (dark-gray) along with different cooling patterns in lava. The 1980 lahar on this side of Mount St. Helens raced through and scoured Lava Canyon. You can still see many fallen trees.

Ape Cave Exploration Guide
Ape Cave Exploration Guide Page 1Ape Cave Exploration Guide Page 2

Ape Cave Photos
Ape Cave Upper Entrance Ape Cave Lava Flow
Lava Canyon Trail
Lava Canyon Suspension Bridge Lava Canyon Trail 184 Ladder

The Diversity of Life

The Diversity of Life - Front Cover
The Diversity of Life (1992) is a book by the eminent American biologist and author E. O. Wilson. If you are not into rolling up your sleeves and getting into science details or you don’t believe the earth is about 4.5 billion years old and all that goes with that, then this book is not for you. The Diversity of Life is a fascinating read that will introduce you to biodiversity, how it’s measured, and how it has changed over earth’s history.

The biodiversity of the world in its simplest definition is the number of distinct biological species. Wilson, when he wrote the book, cited about 1.4 millions species described. Today it is higher, at about 1.8 million species as given at the Encyclopedia of Life. As discussed in The Diversity of Life, the actual number of species is likely much larger by as much as a factor of ten. The current biodiversity of our planet is at its highest level ever, but is being diminished significantly by human activity. This conclusion is arrived at based on estimates of how long species lived and went extinct before humans arrived and comparing that with an estimate how many are going extinct today. For example, Wilson writes that, on average, a species lived on the order of one million years in the absence of human interference and that “human activity has increased extinction between 1,000 and 10,000 times over this level in the rain forest by reduction in area alone.” But lest you go away thinking this is another book about how bad humans are the book really doesn’t leave that impression. Rather, Wilson acknowledges how and why humans are impacting diversity and ends the book by offering five suggestions for preserving as much of earth’s diversity as possible. Without being a plot spoiler the biggest “how” is destruction of habit - see for example the IUCN Red List. The reasons “why” are more numerous and include farmers clearing rainforest to survive and feed families and general unfamiliarity with what species are at stake (the “unknown unknowns” to quote Rumsfeld), to name just two.

There are several interesting ideas that Wilson weaves into the diversity narrative that are worth pointing out:
  • Why do the tropics dominate in biodiversity? Because there is more solar energy available, the climate is more constant, and there are large areas available for life. These three factors are described by Wilson as the Energy-Stability-Area (ESA) Theory of Biodiversity.
  • How many extinction events were there? There were five great extinctions when diversity plummeted dramatically including the Ordovician (440 million years ago), Devonian (365 mya), Permian (245 mya), Triassic (210 mya) and Cretaceous (66 mya) extinctions. The last extinction took out the dinosaurs.
  • Why is biodiversity so high now? According to Wilson, it is due to widely separated continents with long shorelines and stretches of shallow tropical waters with islands. It wasn’t always like that.
  • What is the smallest number of breeding individuals of a species that are considered healthy for that species? Risk of extinction of a species is given approximately by the 50/500 rule. 50 healthy adults are the minimum needed to avoid inbreeding, and 500 for long term viability.
  • Species that have evolved to specialized environments are in general more vulnerable to extinction than less specialized species.
  • The richest nations (mostly northern) preside over the smallest and least interesting biota and conversely, the poorest nations preside over the largest and most diverse biota.
  • Human diets are narrow by choice, not by natural mandate. Our reliance on a fixed number of plants and animals has negative diversity consequences because land cleared to grow these plants and animals can often be utilized more efficiently growing different, often locally tailored choices.
  • Exemptionalism is the belief that humans are a new order of life and are exempt from environmental forces. Wilson urges that we be on guard and that we do not fall prey to exemptionalism by letting species perish and biodiversity decline.

One aspect of the book that is especially nice is the use of ample diagrams, illustrations, and photos interspersed throughout. These, taken with Wilson’s writing style make this an accessible book for a wide range of readers. One hint for reading The Diversity of Life is to check the Notes section for each chapter while reading the chapter. There is valuable information contained in the notes that will help you understand how Wilson reached his conclusions.

In Chapter 14, Resolution, Wilson details five recommendations for preserving the earth’s diversity. The recommendations are aimed not at the reader so much as at society and government. The last chapter (15), The Environmental Ethic, in contrast is aimed at the reader, challenging the reader to acknowledge phobias, any exemptionalist ideas we might have, and ideas that the world is completely explored and we know everything there is to know about it. Still, there are fundamental challenges to having this enlightened “environmental ethic” be widespread, especially when it’s advice coming from one of those biota-challenged rich nations. Wilson writes earlier in the book:

What counts is food today, a healthy family, and tribute for the chief, victory celebrations, rites of passage, feasts. As the Mexican truck driver said who shot one of the last two imperial woodpeckers, largest of all woodpeckers, ‘It was a great piece of meat.’

The Diversity of Life - Back Cover

Thursday, July 1, 2010

Callistemon and Beschorneria

Callistemon bloomingCallistemon just before blooming
Two blooms of note this year at Travelmarx headquarters are from a Callistemon and a Beschorneria plant. Callistemon usually goes by the common name of Bottlebrush because the flowers look as if you could clean a bottle with them. Since ours is red I’m sure now it’s Callistemon citrinus even though the tag that came with the plant said sieberi. We purchased it over a year ago and this is the first time blooming. The Callistemmon has a great form and presence all year round being evergreen; now with the feathery red flowers it’s even better. The genus name Callistemon means beautiful stamens from the Greek 'kalli' or good. The species name citrinus refers to the lemony scent of the leaves. The plant is native to Australia.

The other interesting bloomer this year is a Beschorneria septentrionalis x decosteriana – a soft-leaved agave relative from Mexico. (I’m guessing on the species because the tag that came with the plant read Beschorneria decosternum which doesn’t seem to exist and probably was a typo.) We’ve had it for about three years and it finally bloomed this year. The genus name honors Friedrich Wilhelm Christian Beschorner (1806- 1873), a 19th century German botanist. The species name septentrionalis means northern or belong to the north. In terms of the meaning of decosteriana the web would not reveal the answer so we'll have to let that be a mystery.
Beschorneria sending up stalkBeschorneria in bloom