我正在嘗試獲取登錄到我的應(yīng)用程序中的用戶的Facebook個(gè)人資料圖片。Facebook的API聲明http://graph.facebook.com/517267866/?fields=picture返回正確的URL作為JSON對(duì)象。我想從代碼中獲取圖片的URL。我嘗試了以下操作,但這里缺少內(nèi)容。 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); });運(yùn)行此代碼將導(dǎo)致以下結(jié)果:undefined:1^SyntaxError: Unexpected token o at Object.parse (native)
使用Node.js調(diào)用JSON API
飲歌長(zhǎng)嘯
2019-11-13 14:44:29