Be the envy of all your geekiest friends by using command-line programs to access your favorite sites and online tools. After reading this article series, you’ll be able to update your status on Facebook and Twitter, post to your Blogger and Tumblr accounts, watch YouTube videos, and manage your Flickr albums all from the comfort of your terminal. Today in Part 1, we’ll cover Facebook and Twitter. Let’s go!
You can access most of Facebook’s main features from your Linux, Mac, or Windows command line with fbcmd.
You need to have PHP installed on your system before you can install FBCMD. Once you’ve gotten that out of the way, go ahead and grab the file “fbcmd_update.php”; you can manually download it here or run the following command:
Next run these two commands:
php fbcmd_update.php php fbcmd_update.php install
FBCMD is now installed, but you still need to perform a series of steps to authorize it to access your Facebook account. In your default web browser, log in as the user you want to perform the authorization for. This command will then take you to the basic authorization page:
fbcmd go access
Click “Go to App”; you should be taken to a page that says “Success.” FBCMD still needs authorization to access your account offline. Run:
fbcmd go auth
When this page opens up in your default browser, click “Generate”:
Facebook will then give you an authorization code, which you only need for one-time use. Copy the code and run:
fbcmd auth [code]
If all goes well, you’ll receive a friendly “Welcome to FBCMD” message in your terminal. Finally, grant FBCMD default permissions with:
This will take you to yet another web page, where you must hit the “Allow” button. Now you can proceed to using FBCMD.
All FBCMD commands start with
fbcmd, followed by an argument. Simply type
fbcmd to view all the possible commands. Some examples include:
- Update your status:
fbcmd status "I'm totally updating my Facebook status from the command line!"
- Read your messages:
- Post on your friend Buddy Pal’s wall:
fbcmd wallpost "Buddy Pal" "Wanna rage this Monday night?"
- RSVP to an event:
fbcmd rsvp [event_id] yes|no|maybe
Look no further than the Perl program TTYtter for your command-line Twitter experience. TTytter even supports the StatusNet and Identi.ca APIs in addition to Twitter.
Prereqisites include Perl 5.8.6 or newer and either Lynx or cURL. As of the day I’m writing this article, the latest stable version of TTYtter is 2.0.4 (from October 4, 2012). I recommend downloading the public beta (2.1) instead, as it is compatible with the latest changes in Twitter’s API. To get the beta,
cd into your desired installation directory and run:
wget http://www.floodgap.com/software/ttytter/beta/beta.txt mv beta.txt ttytter chmod +x ttytter ./ttytter
The authorization wizard will start in your terminal. Following the wizard’s instructions, visit the authorization page in your browser.
Generate the PIN and enter it in your terminal following the prompt. By default, the keyfile will be saved as “.ttytterkey” in your home directory.
If you installed TTYtter in a system directory such as /usr/bin, you can run it simply by typing
ttytter. Otherwise, you’ll have to either specify the full path of the executable when you run it or add its directory to your $PATH environment variable. If your terminal supports ANSI colors, start TTYtter with
ttytter command lists recent posts from the users you follow and then opens an interactive session. At the prompt, you can type
/help to list commands or
/quit to exit. Here are some basic commands:
- Make a status update by simply typing it into the prompt:
I'm tweeting from my headless server!
- Refresh to see the newest tweets from the users you follow:
- Display a user’s profile information:
- View your replies and mentions:
- Search Twitter:
For more TTYtter commands and information about scripting TTYtter, see the official documentation. Happy tweeting!
Hungry for more ways to use the command line for social media? Stay tuned for Part 2!