express 및 nodejs를 사용하고 있으며 내 서버에 Facebook 프로필 사진을 저장하는 데 문제가 있습니다. 사진NodeJS : facebook 프로필 사진을 저장하는 방법
위치 : 스크립트를 사용하고 http://profile.ak.fbcdn.net/hprofile-ak-ash2/275619_223605264_963427746_n.jpg
는 :
var http = require('http')
var fs = require('fs')
var options = {
host: 'http://profile.ak.fbcdn.net',
port: 80,
path: '/hprofile-ak-ash2/275619_223605264_963427746_n.jpg'
}
var request = http.get(options, function(res){
res.setEncoding('binary')
var imagedata = ''
res.on('data', function (chunk) {imagedata += chunk})
res.on('end', function(){
fs.writeFile('logo.jpg', imagedata, 'binary', function (err) {
if(err){throw err}
console.log('It\'s saved!');
})
})
})
이미지가 저장되지만 비어 있습니다. 이미지 데이터를 기록하는 콘솔도 비어 있습니다. I followed this example origionally 나를 위해 작동합니다. 그냥 이미지의 위치를 페이스 북 그림으로 변경하면 스크립트가 중단됩니다.
예제 이미지에서 일어나는 일 : p – Mustafa