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

fb-auto-post

v1.0.5

Published

Post or Schedule Random Posts for Facebook Page

Downloads

78

Readme

FB Auto Post

Post or Schedule Random Posts for Facebook Page.

Author: Rainty Yek

License: Apache v2

Installing fb-auto-post

npm install fb-auto-post
// Using import
import AutoPost from 'fb-auto-post';

// Using require()
var AutoPost = require('fb-auto-post');

Library usage

This library can be used to publish post and schedule posts to publish randomly or sequentially to FB pages

AutoPost.initialize({
    app_id: "XXXXXXXXXXX", // (Required) Generate from From Your Facebook Developer App
    app_secret: "XXXXXXXXXXX", // (Required) Generate from From Your Facebook Developer App
    user_access_token: "XXXXXXXXXXX", // (Required) Generate from Facebook Developer Platform Tool, Permissions Needed: public_profile, pages_manage_posts, pages_show_list, pages_read_engagement
    fb_api_url: 'graph.facebook.com', // (Optional) Default: graph.facebook.com
    datasource_src: 'data/autopost-data.json', // (Optional) Default: data/autopost-data.json
}).then((obj) => {
    /**
     * Publish Post Function
     * Template: obj.publishPost(message, type, link, photo, callback)
     * @param {string} message Message Content for the post
     * @param {string} type Post Type (Supported: feed, photo, link)
     * @param {string} link Link to publish (Optional)
     * @param {string} photo Photo URL to publish (Optional)
     * @param {function(?Error, string)} callback A callback function
     * */
    // Post Message
    obj.publishPost('Hi everyone!', 'feed');
    // Post Link
    obj.publishPost('Here\'s my github profile!', 'link', 'https://github.com/raintyyek');
    // Post Photo
    obj.publishPost('This is my github profile picture!', 'photo', null, 'https://avatars.githubusercontent.com/u/93080136?v=4');


    /**
     * Schedule Random Posts
     * Template: obj.randomPosts(json_path, random, loop_times, schedule, timezone)
     * @param {string} json_path File path of JSON Random Posts
     * @param {boolean} random (Optional) (Default: false) Set to True to enable Randomly publish post, else it will publish by ordering in array
     * @param {integer} loop_times (Optional) (Default: 0) Number of times to loop the array, Set to 0 for infinite
     * @param {string} schedule Cron Job Schedule (Optional) (Default: '0 0 * * * *') - Follows format of node-cron (https://www.npmjs.com/package/node-cron)
     * @param {string} timezone Cron Job Timezone (Optional) (Default: Asia/Kuala_Lumpur) - Follows format of node-cron (https://www.npmjs.com/package/node-cron)
     * */
    obj.randomPosts('sample.json', true, 0, '* * * * *'); // Every Minute Publish 1 Post
    obj.randomPosts('sample.json', true, 0, '*/2 * * * *'); // Every 2 Minutes Publish 1 Post
    // ... 
});

JSON format for .randomPosts

[
    {
        "message": "Hi everyone!",
        "type": "feed"
    },
    {
        "message": "Here's my github profile!",
        "type": "link",
        "link": "https://github.com/raintyyek"
    },
    {
        "message": "This is my github profile picture!",
        "type": "photo",
        "photo": "https://avatars.githubusercontent.com/u/93080136?v=4"
    }
]

message - Message Content of Post type - feed / link / photo link - Link to publish (Required when type is link) photo - Photo URL to publish (Required when type is photo)

Refer to src/sample.json

License

This project is licensed under the Apache License, Version 2.0 (the "License"). For more details, see the LICENSE file.

 

Back to top