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。単に画像の位置をFacebookの写真に変更すると、スクリプトが中断されます。
このサンプル画像では何が起こっていますか:p – Mustafa