简体   繁体   English

Node.js Facebook API

[英]Node.js Facebook API

I am new to Node.js and I am having difficulties. 我是Node.js的新手,遇到了困难。 I just wanted someone to explain where I am going wrong. 我只想让某人解释我要去哪里。 I am trying to get stats from my Facebook chats and I wanted to used this API call . 我正在尝试从我的Facebook聊天中获取统计信息,我想使用此API 调用 This is the basic code I have written. 这是我编写的基本代码。

var login = require("facebook-chat-api");

login({email: "Email", password: "Password"}, function callback (err, api) {
    if(err) return console.error(err);
    var threadID = chatNo;
    output = api.getThreadInfo(threadNo)
    console.log(output)

});

When I run this on Node.js the output is "undefined", I cant tell if its because the API call didn't work, or because I am trying to output it incorrectly. 当我在Node.js上运行此输出时,输出是“未定义的”,我无法确定是否是因为API调用不起作用,或者因为我尝试错误地输出它。 Any help would be greatly appreciated. 任何帮助将不胜感激。
Output of Node.js Node.js的输出

You should be using the callback of getThreadInfo like this 您应该像这样使用getThreadInfo的回调

login({email: "Email", password: "Password"}, function callback (err, api) {
    if(err) return console.error(err);
    var threadID = chatNo;
    api.getThreadInfo(threadID, function (err, info) {
        console.log(err, info);
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM