Basic Javascript Use

I am trying to do some basic interactions with Zotero via javascript - for example adding a record. I tried the example code from:
http://dev.zotero.org/interacting_with_zotero_from_within_firefox

And did the following:

var Zotero = Components.classes["@zotero.org/Zotero;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
var data = {
title: "Much Ado About Nothing",
creators: [
['William', 'Shakespeare', 'author']
]
};
var item = Zotero.Items.add('book', data);
But get the following error:
Error: Permission denied to get property XPCComponents.classes

Can someone post some basic sample js code that interacts with Zotero?

Thanks
Andrew
This discussion has been closed.