npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

newgen-fca

v1.0.3

Published

Unofficial Facebook Chat API

Downloads

287

Readme


newgen-fca - Unofficial Facebook Chat API

This is a fork of the original fca-unofficial repository. This version includes new features and updates that are bundled faster than the main repository. However, be aware that new features may also come with some bugs.


Overview

This API allows you to automate Facebook chat functionalities by emulating the browser's GET/POST requests. It does not work with an auth token and requires a Facebook account's AppState (session information), which is obtained via third-party tools.


Important Notes

Login via Credentials Is No Longer Supported

Due to recent changes, the ability to log in using credentials (i.e., email and password) directly through the API has been disabled. As a result, you cannot use the old login method with your email and password anymore.

api.getAppState finally works!

To use the API, you need to provide an AppState (session information) from a previously authenticated session. You can use api.getAppState() to retrieve and even update your AppState after login.

  • Kiwi Browser & c3c-ufc-utility Extension: Extract the AppState using the Kiwi Browser along with the c3c-ufc-utility extension to obtain session cookies after logging into Facebook manually.

Once you have the AppState, you can load it into the API to authenticate. Additionally, api.getAppState() can now be used to update the AppState during the session.

We strongly recommend being responsible when using this API to avoid issues like account bans. Avoid spamming messages, sending large amounts of requests, or using excessive automation.


New Features

1. BypassAutomationBehavior

This feature is designed to bypass certain behavior detection mechanisms from Facebook, which may otherwise flag your actions as automated. By enabling this, your bot's activity will appear more like human interaction, helping reduce the risk of account limitations.

  • Configuration: Can be toggled on or off in the NextGen-FCA.json configuration file.

2. AutoRefreshFbDtsg

This feature automatically refreshes the fb_dtsg token, which is used for secure communication with Facebook. Since fb_dtsg tokens expire periodically, this feature ensures your session stays active by refreshing the token automatically without requiring a manual login.

  • Configuration: Can be toggled on or off in the NextGen-FCA.json configuration file.

How to Get AppState

  1. Kiwi Browser & c3c-ufc-utility Extension
    • Install Kiwi Browser and the c3c-ufc-utility extension.
    • Use the extension to extract your AppState (session cookies) from your Facebook login.
    • Save the AppState as a appstate.json file and load it for logging in.

For more details, check the official c3c-ufc-utility GitHub release.


Install

To install newgen-fca, use the following npm command:

npm install newgen-fca

To install the bleeding-edge version directly from GitHub:

npm install newgen-fca/newgen-fca

Example Usage

Here’s how to log in using AppState:

const fs = require('fs');
const login = require('newgen-fca');

// Load your appState from the saved file
const appState = JSON.parse(fs.readFileSync('appstate.json', 'utf8'));

// Use the appState for login
login({ appState: appState }, (err, api) => {
    if (err) return console.error('Login failed:', err);

    console.log('Successfully logged in!');

    // Example of listening for new messages
    api.listen((err, message) => {
        if (err) return console.error(err);

        // Respond to the received message
        api.sendMessage(message.body, message.threadID);
    });

    // Get and update AppState if needed
    const updatedAppState = api.getAppState();
    fs.writeFileSync('appstate.json', JSON.stringify(updatedAppState));
});

Configuration (NextGen-FCA.json)

The following options can be configured in your NextGen-FCA.json file:

{
  "BypassAutomationBehavior": true,  // Set to false to disable this feature
  "AutoRefreshFbDtsg": true         // Set to false to disable this feature
}
  • BypassAutomationBehavior: Enables or disables the feature to bypass Facebook's automated behavior detection.
  • AutoRefreshFbDtsg: Enables or disables automatic refreshing of the fb_dtsg token to keep your session active.

Main Functionality

  • Sending Messages:

    • Regular Text Messages
    • Sticker Messages
    • Image/File Attachments
    • URLs
    • Emojis
  • Listening to Messages:

    • Listen to messages in real-time
    • Option to listen to events like user joining or leaving a chat

FAQ

  1. How can I log in without credentials?

    • After logging in through a browser, extract your AppState using the c3c-ufc-utility extension. This is now the only way to authenticate.
  2. Can I listen to messages from the bot?

    • Yes, by default, the bot listens to incoming messages and can respond automatically. You can configure it to respond with specific actions based on the message content.
  3. Is there a way to send media like images or files?

    • Yes, you can send files or images by passing them as attachments. The example provided demonstrates how to send an image along with a text message.
  4. How do I keep my session alive?

    • You do not need to log in repeatedly once you have your AppState saved. Simply load the appState.json each time you initialize the API.
  5. Can I send messages as a Facebook Page?

    • Yes, you can configure the login to use a Facebook Page ID for sending messages as a Page. This is done during the login step.

Projects Using This API

  • c3c - A customizable bot with Facebook and Discord support.
  • Messenger-CLI - Command-line interface for Facebook Messenger.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Contact & Community

If you have a problem with this FCA, you can contact us by clicking here:

Join our group ChatBot Community:


Note: This project is an unofficial Facebook chat API. Use it responsibly and follow Facebook’s terms of service.