无法使用node.js与Facebook的graphicsAPI进行交互

这是我试图打的url:

https://graph.facebook.com/v2.8/me?fields=friends?access_token=xxxx. 

预期结果:(如图表API资源pipe理器):

 { "friends": { "data": [ ], "summary": { "total_count": 648 } }, "id": "xxxx" } 

打电话给朋友的号码:(node.js)

 fb.getFbData(constants.AccessToken, 'me?fields=friends', function(data){ res.send(data); }); 

取数的朋友的方法:(node.js)

 var https = require('https'); exports.getFbData = function(accessToken, apiPath, callback) { var options = { host: 'graph.facebook.com', port: 443, path: apiPath + '?access_token=' + accessToken, //apiPath example: '/me/friends' method: 'GET' }; console.log("\n\n options:::", options); var buffer = ''; //this buffer will be populated with the chunks of the data received from facebook var request = https.get(options, function(result){ result.setEncoding('utf8'); result.on('data', function(chunk){ buffer += chunk; }); result.on('end', function(){ callback(buffer); }); }); request.on('error', function(e){ console.log('error from facebook.getFbData: ' + e.message) }); request.end(); } 

错误:

在这里输入图像说明

有两件事错了:

  1. 不正确的url,正在传递的第二个参数在URL中没有“&”。

  2. 当像这样的调用使用https.get和'options'时:

    var options = {host:'graph.facebook.com',port:443,path:apiPath +'?access_token ='+ accessToken,method:'GET'};

然后,“主机”被附加到URL中,因此“path”只需要包含网站上的目录。 例如:/v2.8/me?fields=friends