Created
March 2, 2016 11:09
-
-
Save gabrielstuff/b0bd527c16da511c3506 to your computer and use it in GitHub Desktop.
history from periscope
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
const request = require('request') | |
const _ = require('lodash') | |
const postData = { | |
access_token:"28h9_iVDARWp5YD8R9_9c4ECK6kcLyXl6cRmc2m28htKORykzgU9w3QkYkUFLc98K61_Ecc9y4-j3bwvW9UpyinCPnf0FfG4bbkwvEwVqPA8ozyXtxd3zJaAo6DMDcVbRqU1XPMnQrk3FIgAwijyGYRft3LvvGd-ALYuI3xg_7R-5yamkd49xgnG6FduR7iuENi5TavP1vCKGaC2Dyia8Z99nWst8-bcwe5Y2beKjB0qcGLJdjFeHEsatox2jBmUuR-CmmPjS57Cz", | |
cursor:"", | |
limit:1000, | |
since:0 | |
} | |
var url = 'https://chatman-eu-central-1.periscope.tv/k=1ypKdWqyPOgxW/chatapi/v1/history' | |
var options = { | |
method: 'post', | |
body: postData, | |
json: true, | |
url: url | |
} | |
request(options, function (err, res, body) { | |
if (err) { | |
console.log(err, 'error posting json') | |
return | |
} | |
var headers = res.headers | |
var statusCode = res.statusCode | |
var messages = _.map(body.messages, function(el){ | |
try{ | |
var mainContent = JSON.parse(el.payload) | |
var bodyMessage = JSON.parse(mainContent.body) | |
var message = { | |
sender: mainContent.sender, | |
content: bodyMessage, | |
timestamp: mainContent.timestamp | |
} | |
return message | |
} catch (err){ | |
return {} | |
} | |
}) | |
console.log('messages:', messages) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment