我正在try 获取登录到我的应用程序的用户的facebook个人资料图片.Facebook的API声明http://graph.facebook.com/517267866/?fields=picture
以JSON对象的形式返回正确的URL.
我想从我的代码中获取图片的URL.我try 了以下方法,但我遗漏了一些东西.
var url = 'http://graph.facebook.com/517267866/?fields=picture';
http.get(url, function(res) {
var fbResponse = JSON.parse(res)
console.log("Got response: " + fbResponse.picture);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
运行此代码会产生以下结果:
undefined:1
^
SyntaxError: Unexpected token o
at Object.parse (native)