Last active
July 20, 2018 22:16
-
-
Save eSlider/ff43df5967adfa55f05a6138689ad516 to your computer and use it in GitHub Desktop.
Get over HTTPS
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
/** | |
* Get this fucking object | |
* | |
* @param {String} url URL я для http не учитывал | |
* @param {Function} onData(data) колбэк когда всё норм, будет вызван с уже готовым объектом | |
* @return {*} | |
*/ | |
function getThisFuckingJsonObject(url, onData) { | |
let chunks = []; | |
return require('https').get(url, res => { | |
res.setEncoding('utf8') | |
.on('data', (chunk) => { | |
chunks.push(chunk); | |
}) | |
.on('end', () => { | |
onData(JSON.parse(chunks.join(''))); | |
}); | |
}).on('error', function(e) { | |
console.log("Got an error: ", e); | |
}); | |
} | |
// Незабудь что запрос HTTPS, для него нужено: npm install https | |
let url = 'https://pu.vk.com/c840322/upload.php?act=do_add&mid=213468131&aid=-14&gid=156603484&hash=3adf9a37525310429755decdb02fa76b&rhash=caea51e027944fd81a5a4ae5b15a77c6&swfupload=1&api=1&wallphoto=1'; | |
getThisFuckingJsonObject(url, data => { | |
console.log(data.server, data.photo, data.hash); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment