Created
September 13, 2011 20:48
-
-
Save dbamber/1215122 to your computer and use it in GitHub Desktop.
List fusion tables from google docs api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: David Bamber <[email protected]> | |
* http://bmbr.co | |
* | |
* Usage: node test.js <googleuser> <googlepass> | |
* | |
* Requires: googleclientlogin (npm install googleclientlogin) | |
* | |
*/ | |
var user = process.argv[2]; | |
var pass = process.argv[3]; | |
var url = '/feeds/default/private/full/-/table'; | |
function get(url,callback) | |
{ | |
var options = { | |
host: 'docs.google.com', | |
port: 443, | |
path: url, | |
method: 'GET', | |
headers: { | |
'Authorization': 'GoogleLogin auth=' + ga.getAuthId() | |
,'GData-Version': '3.0' | |
} | |
}; | |
var req= require('https').request(options,callback); | |
req.end(); | |
} | |
var google2=require('googleclientlogin'); | |
var gac = google2.GoogleClientLogin; | |
var ga = new gac({ | |
email: user, | |
password: pass, | |
service: 'docs', | |
accountType: gac.accountTypes.google | |
}) | |
ga.on(gac.events.login, function(){ | |
var resFunc = function (res) | |
{ | |
res.on('data', function (chunk) { | |
var res = chunk.toString().match('<id>(.*?)</id>.*?<title>(.*?)</title>'); | |
if (res) | |
{ | |
console.log('Title: ' + res[2] + ' ID: ' + res[1]); | |
} | |
}); | |
}; | |
get(url,resFunc); | |
}); | |
ga.on(gac.events.error, function(e) { | |
console.log('ERROR'); | |
}); | |
ga.login(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment