/facebook-cli

Facebook interaction from the command line

Primary LanguageRuby

Facebook CLI

Facebook command line interface

Demo

Install

gem install facebook-cli

Facebook configuration

The following steps are necessary to use the Facebook API:

  • Create a new application at: https://developers.facebook.com/apps
  • In the "Settings" tab, set "Site URL" to http://localhost and then add localhost to the "App Domains"
  • In the "App Review" tab, flip the switch to make your app live. This is required for the content you publish through this app to be visible to other users.
  • Save the App ID and App Secret by running: facebook-cli config --appid=<app-id> --appsecret=<app-secret>

Run

facebook-cli login
facebook-cli likes

Commands

Running facebook-cli help shows the list of available commands:

COMMANDS
    config     - Save Facebook application ID and secret
    event      - Show event details
    events     - List your upcoming events
    feed       - List the posts on your profile
    friends    - List the people you are friends with (some limitations)
    help       - Shows a list of commands or help for one command
    likes      - List the pages you have 'Liked'
    links      - Some useful URLs
    login      - Log into Facebook and receive an access token
    logout     - Deauthorize your access token
    me         - Show your profile information
    pastevents - List your past events
    photos     - List photos you have uploaded
    photosof   - List photos you are tagged in
    post       - Post a message or image to your timeline
    postlink   - Post a link to your timeline
    postvideo  - Post a video to your timeline
    videos     - List videos you have uploaded
    videosof   - List videos you are tagged in

Running facebook-cli help <command> may reveal more details.

Converting output to HTML

The output can easily be converted to an HTML document using a Markdown renderer. For example, with Pandoc:

facebook-cli likes | pandoc -s -f markdown_github > likes.html

Why can't I...?

Facebook has removed a large portion of their Graph API starting with version 2.0. Niraj Shah has done a fantastic job documenting the cutbacks and their implications in these blog posts:

With so much functionality removed, it's not possible to build a full-featured interface to Facebook using the API.

If you can get a feature to work, open a pull request.

Development

Install dependencies with Bundler:

gem install bundler
bundle install

License

MIT