@ibrahemvx2000/fca-unofficial
v1.3.33
Published
A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.
Downloads
6
Readme
@ibrahemvx2000/fca-unofficial
Unofficial Facebook Chat API
This API allows you to automate chat functionalities on a user account by emulating the browser. It achieves this by making the exact same GET/POST requests as if accessing the website normally. However, please note that this API requires the credentials of a Facebook account and does not work with an auth token.
Disclaimer: We want to emphasize that we are not responsible if your account gets banned for engaging in spammy activities such as sending large numbers of messages to unknown individuals, rapidly sending messages, sending suspicious-looking URLs, or frequently logging in and out. Please be a responsible user and respect Facebook's policies.
Installation
If you wish to use @ibrahemvx2000/fca-unofficial
, you can install it via NPM using the following command:
npm install @ibrahemvx2000/fca-unofficial
This command will download and install @ibrahemvx2000/fca-unofficial
from the NPM repositories.
Testing Your Bots
If you wish to test your bots without creating another Facebook account, you can use Facebook Whitehat Accounts: https://www.facebook.com/login.php?next=https%3A%2F%2Fwww.facebook.com%2Fwhitehat%2Faccounts%2F
Example Usage
Here's an example of creating a simple echo bot using the API:
const login = require("@ibrahemvx2000/fca-unofficial");
// Create a simple echo bot
login({ email: "FB_EMAIL", password: "FB_PASSWORD" }, (err, api) => {
if (err) return console.error(err);
api.listenMqtt((err, message) => {
api.sendMessage(message.body, message.threadID);
});
});
Documentation
Main Functionality
Sending a Message
To send a message, you can use the api.sendMessage()
function. Various types of messages can be sent, including regular messages, stickers, files/images, URLs, and emojis:
api.sendMessage(message, threadID[, callback][, messageid]);
FAQ
How do I run tests?
To run tests, create a test-config.json
file similar to example-config.json
and place it in the test
directory. Then, run npm test
from the root directory.
Why doesn't sendMessage always work when I'm logged in as a page?
Pages cannot initiate conversations with users directly to prevent spamming.
What do I do when login doesn't work?
First, check if you can log in to Facebook using the website. If login approvals are enabled, make sure you are logging in correctly. Refer to the login documentation for handling login approvals.
How can I avoid logging in every time? Can I log into a previous session?
You can cache relevant data to bypass login using api.getAppState()
, which returns an object that you can save and pass into login as {appState: mySavedAppState}
instead of the credentials object.
Do you support sending messages as a page?
Yes, you can set the pageID
option on login. Refer to the documentation for an example.
I'm getting some crazy weird syntax error like SyntaxError: Unexpected token [!!!
Please try updating your version of Node.js before submitting an issue of this nature, as newer language features might be used.
I don't want all of these logging messages!
You can use api.setOptions
to silence the logging. For example, api.setOptions({logLevel: "silent"})
.