Paweł Iżycki

.NET developer, fan of automation and backend world.


Facebook chat in cmd

03 Aug 2016 » .NET, Edge.js, Facebook

Install NPM package manager

choco install nodejs npm -y

Create Console Application.

Install Edge.js with NuGet.

Install-Package Edge.js

Open cmd in root of your Console app and install facebook-chat-api module

npm install facebook-chat-api

Then insert snippet below for messaging you on FB by running application.

using System;
using System.Threading.Tasks;
using EdgeJs;

namespace ConsoleApplication1
{
    class Program
    {
        public static async Task Start()
        {
            var func = Edge.Func(@"

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

return function (data, cb) {
    login({email: data.email, password: data.password}, function callback (err, api) {
        if(err) return console.error(err);
        api.sendMessage(data.body, data.thread);
    });

    cb();
}

        ");

            Console.WriteLine(await func(new
            {
                email = "XXXXXXXXXX",
                password = "XXXXXXXX",
                body = "blabla",
                thread = "100000548414228" // Tip: to find your own ID, you can look inside the cookies. The userID is under the name `c_user`
            }));
        }

        static void Main(string[] args)
        {
            Start().Wait();
            Console.ReadKey();
        }
    }
}

You can explore examples for more cool usages.


Image: Iris Classon Blog