Created
March 25, 2016 00:17
-
-
Save clstl/f3a236fd72ee475c841a to your computer and use it in GitHub Desktop.
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
/* == Imports == */ | |
var AWS = require('aws-sdk'); | |
var path = require('path'); | |
var http = require('http'); | |
var elasticsearch = require('elasticsearch'); | |
var client = new elasticsearch.Client({ | |
host: 'search-guptadaniel-onk2zd5ibnyd646ohpu7tfmkv4.us-west-2.es.amazonaws.com', | |
log: 'trace' | |
}); | |
function getTestPersonaLoginCredentials(callback, context) { | |
return http.get({ | |
host: 'https://api.instagram.com', | |
path: '/v1/media/1213282857430725126_2942723755/comments?access_token=2942723755.2436505.fdda1ad9112f46caa0b1e2678bca97d2' | |
}, function(response) { | |
// Continuously update stream with data | |
var body = ''; | |
response.on('data', function(d) { | |
body += d; | |
}); | |
response.on('end', function() { | |
// Data reception is done, do whatever with it! | |
var parsed = JSON.parse(body); | |
var data = body.data; | |
var usrArray = []; | |
for(var i = 0; i < data.length ; i++ ) { | |
var obj = {}; | |
obj['username'] = data[i].from.username; | |
obj['text'] = data[i].text; | |
usrArray.push({ create: { _index: 'test420', _type: 'json', _id: i*10 }}); | |
usrArray.push(obj); //fuck off | |
} | |
client.bulk({body: usrArray}, function (err, resp) {context.succeed(resp);}); | |
}); | |
}); | |
}, | |
exports.handler = function(event, context) { | |
getTestPersonaLoginCredentials({},context) | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment