Facebook functionality from the command line.
gem install facebook-cli
(might require sudo)
To interact with the Facebook API you must create and configure a Facebook application for your personal use.
- Go to https://developers.facebook.com/apps and click "Add a New App"
- Go to the "Settings" tab
- Click "Add Platform"
- Select "Website"
- Set "Site URL" to
http://localhost
- Add
localhost
to the "App Domains" - Click "Save Changes"
- Go to the "App Review" tab
- Flip the switch that says "Your app is in development and unavailable to the public."
- Click "Confirm" to make your app live (this is required for any content you publish through this app to be visible to other users)
- Go to the "Dashboard" tab
-
Under "App Secret" click "Show" to reveal your app secret
-
Open a terminal and save your App ID and App Secret by running:
facebook-cli config --appid=<app-id> --appsecret=<app-secret>
-
See: detailed instructions with screenshots
Once the Facebook app is configured, you must authorize it to access the social graph as you.
- In a terminal, run:
facebook-cli login
- Open the given URL in a web browser, and log into your Facebook account if prompted
- Click "Continue" to approve the permissions
- Select the scope of your audience for any posts you publish using this application (read more)
- Click "Ok" to continue
- Close the browser tab
See: detailed instructions with screenshots
facebook-cli login
facebook-cli me
Running facebook-cli help
shows the list of available commands:
COMMANDS
api - Make a Facebook API request
config - Save your Facebook API credentials
event - Show event details
events - List your upcoming events
feed - List posts on your profile
friends - List people you are friends with (some limitations)
help - Shows a list of commands or help for one command
likes - List pages you have 'Liked'
links - Some useful URLs
login - Request Facebook permissions and receive an API 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, a page or a group
postlink - Post a link to your timeline, a page or a group
postvideo - Post a video to your timeline, a page or a group
tagged - List stories you are tagged in
videos - List videos you have uploaded
videosof - List videos you are tagged in
Run facebook-cli help <command>
for more details on each command.
Use a Markdown renderer to easily convert the output to an HTML document. For example, using Pandoc:
facebook-cli likes | pandoc -s -f markdown_github > likes.html
See: example
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:
- Facebook API: Graph API v2.4 Released, Removes Groups, Notifications and Stream Permissions
- Facebook Announces Graph API v2.3, More Deprecations
- Facebook API: Getting Friends Using Graph API 2.0 and PHP SDK 4.0.x
An article published in October, 2012 by Facebook developer Henry Zhang provides insight into the reasoning:
Post to friends wall via the API generate a high levels of negative user feedback, including “Hides” and “Mark as Spam" and so we are removing it from the API. If you want to allow people to post to their friend’s timeline from your app, you can invoke the feed dialog.
The functionality removed renders it impossible to build a full-featured interface to Facebook through the Graph API alone.
If you expand the functionality, please open a pull request.
Clone this repository, then use Bundler to install Ruby dependencies:
gem install bundler
bundle install
You should now be able to run facebook-cli from the bin
directory:
bin/facebook-cli
facebook-cli depends on the Koala library for interfacing with Facebook's Graph API and GLI for parsing command line arguments.
Using a ruby environment manager such as rbenv or rvm is advisable to avoid environment conflicts between projects.
Please read the guide on how to contribute.
Applications:
- vhpoet/facebook-cli (Facebook CLI written in NodeJS)
- fb-messenger-cli (Facebook Messenger for the terminal)
- Messenger for Desktop (Facebook Messenger standalone app)
Libraries:
- Koala (Ruby)
- facebook-node-sdk (JavaScript)
ISC