我正在尝试获取登录到我的应用程序的用户的facebook个人资料图片。Facebook的API指出,http://graph.facebook.com/517267866/?fields=picture
以JSON对象的形式返回正确的URL。
我想从我的代码中获得图片的URL。我尝试了下面的方法,但是我遗漏了一些东西。
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)
https://stackoverflow.com/questions/11826384
复制相似问题