我正在嘗試獲取登錄到我的應用程序中的用戶的Facebook個人資料圖片。Facebook的API聲明http://graph.facebook.com/517267866/?fields=picture返回正確的URL作為JSON對象。我想從代碼中獲取圖片的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)
使用Node.js調用JSON API
飲歌長嘯
2019-11-13 14:44:29