Permalink
Browse files

updated readme and and samples

  • Loading branch information...
1 parent 9583b2f commit 68f50ccf6d734dfb1a54accab33b68d5b797c5c4 @chrismatthieu committed Dec 22, 2011
View
@@ -11,7 +11,7 @@ To get started you will first need to have Node.js installed. Howtonode has a go
If you have Node.js installed, and are using the Node Package Manager (npm), just do:
-~$ npm install tropo-webapi
+~$ npm install tropo-webapi -g
If you install with npm, then you can reference the tropo Node library in your node.js scripts like this:
@@ -30,10 +30,10 @@ If you do not have npm installed, then you will then want to create a directory
|-vendor
</pre>
-Next copy the tropo-webapi-node/lib/tropo-webapi.js & tropo-webapi-node/lib/base.js in the project/lib directory. Then you may create a server.js file in the project directory that requires the Tropo WebAPI Node library as follows:
+Add this declaration to your server.js starting file
<pre>
- require('../lib/tropo-webapi');
+ var tropowebapi = require('tropo-webapi');
</pre>
Running
@@ -52,14 +52,14 @@ Generate a JSON Doc
-------------------
<pre>
- require('tropo-webapi');
+ var tropowebapi = require('tropo-webapi');
var sys = require('sys');
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello, World.");
- sys.puts(TropoJSON(tropo));
+ sys.puts(tropowebapi.TropoJSON(tropo));
</pre>
Respond to a Tropo WebAPI Session
@@ -72,17 +72,17 @@ Respond to a Tropo WebAPI Session
*/
var http = require('http');
- require('tropo-webapi');
+ var tropowebapi = require('tropo-webapi');
var server = http.createServer(function (request, response) {
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello, World!");
// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
- response.end(TropoJSON(tropo));
+ response.end(tropowebapi.TropoJSON(tropo));
}).listen(8000); // Listen on port 8000 for requests.
</pre>
@@ -3,18 +3,18 @@
* Express must be installed for this sample to work
*/
-require('../../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();
app.post('/', function(req, res){
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Hello World!");
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
@@ -3,37 +3,37 @@
* Express must be installed for this sample to work
*/
-require('../../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();
app.post('/', function(req, res){
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Welcome to my Tropo Web API node demo.");
// Use the on method https://www.tropo.com/docs/webapi/on.htm
tropo.on("continue", null, "/one", true);
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
app.post('/one', function(req, res){
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello from resource one!");
tropo.on("continue", null, "/two", true);
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
app.post('/two', function(req, res){
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello from resource two!");
tropo.say("Well, enough of that. Goodbye.");
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
app.listen(8000);
View
@@ -3,7 +3,7 @@
* Express must be installed for this sample to work
*/
-require('../../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();
@@ -17,7 +17,7 @@ app.configure(function(){
app.post('/', function(req, res){
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Welcome to my Tropo Web API node demo.");
@@ -31,15 +31,15 @@ app.post('/', function(req, res){
// use the on method https://www.tropo.com/docs/webapi/on.htm
tropo.on("continue", null, "/answer", true);
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
app.post('/answer', function(req, res){
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Your zip code is " + req.body['result']['actions']['interpretation']);
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
app.listen(8000);
@@ -3,7 +3,7 @@
* Express must be installed for this sample to work
*/
-require('../../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();
@@ -19,12 +19,12 @@ app.post('/', function(req, res){
console.log(req.body)
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("You are a " + req.body['session']['userType']);
tropo.say("Did you not know that already? Goodbye.")
- res.send(TropoJSON(tropo));
+ res.send(tropowebapi.TropoJSON(tropo));
});
@@ -4,16 +4,16 @@
*/
var http = require('http');
-require('../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var server = http.createServer(function (request, response) {
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello, World!");
// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
- response.end(TropoJSON(tropo));
+ response.end(tropowebapi.TropoJSON(tropo));
}).listen(8000); // Listen on port 8000 for requests.
@@ -4,15 +4,15 @@
* ~$ node path/to/tropo-webapi-node/samples/sample-1.js
*/
-require('../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
// Create a new instance of the TropoWebAPI object.
-var tropo = new TropoWebAPI();
+var tropo = new tropowebapi.TropoWebAPI();
// Say something and then hangup. (Note, null values are excluded from rendered JSON.)
tropo.say("Hello, World.", null, null, true, "carmen");
tropo.hangup();
// Write out the rendered JSON.
-sys.puts(TropoJSON(tropo));
+sys.puts(tropowebapi.TropoJSON(tropo));
@@ -5,14 +5,14 @@
*
*/
-require('../../lib/tropo-provisioning');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
var userid = '';
var password = '';
var applicationID = '';
-var p = new TropoProvision(userid, password);
+var p = new tropowebapi.TropoProvision(userid, password);
p.updateApplicationAddress(applicationID, 'aim', null, null, null, null, null, 'AIMUser01', 'password', null);
@@ -6,14 +6,14 @@
*
*/
-require('../../lib/tropo-provisioning');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
var userid = '';
var password = '';
var applicationID = '';
-var p = new TropoProvision(userid, password);
+var p = new tropowebapi.TropoProvision(userid, password);
p.updateApplicationAddress(applicationID, 'number', '1407', null, null, null, null, null, null, null);
@@ -5,14 +5,14 @@
*
*/
-require('../../lib/tropo-provisioning');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
var userid = '';
var password = '';
var applicationID = '';
-var p = new TropoProvision(userid, password);
+var p = new tropowebapi.TropoProvision(userid, password);
p.updateApplicationAddress(applicationID, 'token', null, null, null, null, 'messaging', null, null, null);
@@ -7,7 +7,7 @@
*
*/
-require('../../lib/tropo-provisioning');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
var userid = '';
@@ -18,7 +18,7 @@ var messagingURL = 'http://somefakehost.com/tropo/app.json';
var platform = 'webapi';
var partition = 'staging';
-var p = new TropoProvision(userid, password);
+var p = new tropowebapi.TropoProvision(userid, password);
p.createApplication(name, voiceURL, messagingURL, platform, partition);
@@ -4,15 +4,15 @@
*
*/
-require('../../lib/tropo-provisioning');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
var userid = '';
var password = '';
var applicationID = '';
var myNumber = '';
-var p = new TropoProvision(userid, password);
+var p = new tropowebapi.TropoProvision(userid, password);
p.deleteApplicationAddress(applicationID, 'number', myNumber);
@@ -5,14 +5,14 @@
*
*/
-require('../../lib/tropo-provisioning');
+var tropowebapi = require('tropo-webapi');
var sys = require('sys');
var userid = '';
var password = '';
var applicationID = '';
-var p = new TropoProvision(userid, password);
+var p = new tropowebapi.TropoProvision(userid, password);
p.deleteApplication(applicationID);
@@ -6,7 +6,7 @@
var http = require('http');
-var tropo = require('../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var server = http.createServer(function (request, response) {
@@ -30,7 +30,7 @@ var server = http.createServer(function (request, response) {
request.addListener('end', function() {
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
if(pathname == '/') {
@@ -61,7 +61,7 @@ var server = http.createServer(function (request, response) {
// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
- response.end(TropoJSON(tropo));
+ response.end(tropowebapi.TropoJSON(tropo));
})
}
View
@@ -4,12 +4,12 @@
*/
var http = require('http');
-require('../lib/tropo-webapi');
+var tropowebapi = require('tropo-webapi');
var server = http.createServer(function (request, response) {
// Create a new instance of the TropoWebAPI object.
- var tropo = new TropoWebAPI();
+ var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Welcome to my Tropo Web API node demo.");
// Demonstrates how to use the base Tropo action classes.
@@ -22,6 +22,6 @@ var server = http.createServer(function (request, response) {
// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
- response.end(TropoJSON(tropo));
+ response.end(tropowebapi.TropoJSON(tropo));
}).listen(8000); // Listen on port 8000 for requests.
Oops, something went wrong.

0 comments on commit 68f50cc

Please sign in to comment.