-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpush
executable file
·29 lines (22 loc) · 900 Bytes
/
push
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
var fs = require('fs')
var request = require('request')
var command
var program = require('commander');
program
.version('0.0.0')
.option('-u, --url <url>', 'URL of the Phant server. Ex. http://data.sparkfun.com')
.option('-s, --public_key <public_key>', 'The public key Phant gave you for this stream')
.option('-p, --private_key <private_key>', 'The private key Phant gave you for this stream')
.option('-f, --field_name <field_name>', 'Field name you told Phant you would use for this stream')
.option('-d, --data <data>', 'Data! Yum yum.')
.parse(process.argv);
var iri = program.url + '/input/' + program.public_key +
'?private_key=' + program.private_key +
'&' + program.field_name + '=' + program.data
console.log('Sending GET: ' + iri)
request
.get(iri)
.on('response', function(response) {
console.log(response.statusCode) // 200
})