Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send facebook message from linux console (command-line)

Old days many admins use sms-gates for sending important informations from their systems e.g. "Power down, UPS is working now!", "Power Up, UPS is off!" or "CPU Temp too high!". Today in Facebook era we use messenger instead of SMS, so I wonder if I could create a command-line bash or php script for such thing.

The idea - cron checks every 10 minutes the condition and if it is true, sends message to my messenger.

The issues:

  1. I don't want to use my fb account for sending - I'd like to get message from "System 1", "System 2", because i have more than one system to admin.
  2. The bash part is easy for me, I need tips for Facebook solutions:
    • do I have to get FacebookAppId (and do I have to create AppId for each system or just one AppId)
    • how to "join/confirm/accept" "System 1" account with my Facebook Account
    • is it possible to send messages to more than one FBAccount
    • any other hints what should i look for.

I found Notification App, but i think that it doesn't send message to messenger, so it would be useless.

like image 262
Tomasz Brzezina Avatar asked May 15 '15 07:05

Tomasz Brzezina


People also ask

How do I send a broadcast message in Linux?

Broadcasting a Message To see all the logged-in users, run the w or who command. The wall command will wait for you to enter text. When you're done typing the message, press Ctrl+D to end the program and broadcast the message.


2 Answers

So there are a couple of command line apps to do this.

There is a libpurple extension (https://github.com/dequis/purple-facebook) which works. However purple doesn't seem to support the idea of message history. This is a shame since I imagine offline messages is the default way most people use facebook.

There is an single use command tool for facebook as well: https://www.npmjs.com/package/fb-messenger-cli which does support history. Unfortunately this is a TUI rather than a command line application and doesn't seem to depend on a separate facebook library. Some hacking or terrible expect glue could work around this.

like image 147
Att Righ Avatar answered Oct 19 '22 00:10

Att Righ


The Chat API was removed with v2.0 of the Graph API, there is no way to send messages with an API anymore. Btw, messages are for communcation between real users, they should not be used as notification system anyway. SMS is still a good option for those kind of warnings imho.

Using a Page and the /conversations endpoint would not work either:

Pages can only reply to a message - they cannot initiate a conversation. Also, a Page can only respond twice to a particular message, the other party will have to respond before they can reply again.

Source: https://developers.facebook.com/docs/graph-api/reference/v2.3/conversation/messages#publish

like image 27
andyrandy Avatar answered Oct 19 '22 01:10

andyrandy