Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr1799 :: Posting From the Command Line on Open Social Networks

I explain how to post content from the command line on open social networks pump.io and GNU Social

<< First, < Previous, , Latest >>

Thumbnail of Jon Kulp
Hosted by Jon Kulp on Thursday, 2015-06-25 is flagged as Clean and is released under a CC-BY-SA license.
scripting, command-line, social media, GNU Social, pump.io. (Be the first).
The show is available on the Internet Archive at: https://archive.org/details/hpr1799

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:12:44

general.

Posting From the Command Line on Open Social Networks

You can post to your open social media timelines from the command line using API access. Why would you want to do this?

  • Script automated postings.
  • Bots
  • Post from terminal environments.
  • Post from wherever else you are without having to go to the social media site or to the client that you use to access it.
  • Trigger postings via voice command (what I do).

On GNU Social

Here is the basic format for the command to post a message to a Statusnet / GNU Social timeline:

curl -s --basic --user <username:password> --data status="Hello World" --output /dev/null https://instance.domain.com/api/statuses/update.xml

And here is the script I use to post a message to my timeline, launched by a blather voice command:

#!/bin/bash

# SN account info
user=johndoe
pass='password123'

# a place to store the text message 
text=/tmp/message.txt

# Virtual keystrokes to copy selected text to the clipboard
xdotool key Control+c

# pipe text out of clipboard into the text file
xclip -o > $text

# rest for half a sec
sleep .5

curl -s --basic \
--user $user:$pass \
--data status="$(cat "$text")" \
--output /dev/null \
https://instance.domain.com/api/statuses/update.xml 

rm $text

exit 0

On Pump.io

On pump.io you have to install the pump.io software on your computer. You don't have to be running a server, you just have to have the binaries so that you can run the commands. I will not go into how this is done on this podcast, but there's a link to the pump.io website below and there should be installation instructions available there. Once you have the software installed, you also have to allow command-line access to your account and get the token for authentication, maybe authorize the user too:

pump-register-app -s instance.domain.com -P 443 -t CLI
pump-authorize -s instance.domain.com -P 443 -u username

Finally you can post to your timeline from the command line:

pump-post-note -s instance.domain.com -P 443 -p -u username -n "Hello World."

My script to post a message to the pump.io timeline, launched by a blather voice command:

#!/bin/bash

# a place to put the text. 
text=/tmp/message.txt

# --------------------------------
# Since markdown is possible, I run 
# the text through markdown to get
# a bit of formatting and save it
# as a separate file 
# --------------------------------
pump=/tmp/pump.txt

# Virtual keystrokes to copy selected text to the clipboard
xdotool key Control+c

# pipe text out of clipboard into the text file
xclip -o > $text

# run Markdown
markdown $text > $pump

# Post message
pump-post-note -s instance.domain.com -P 443 -p -u username -n "$(cat $pump)"

sleep 1

rm $text
rm $pump

exit 0

Links


Comments

Subscribe to the comments RSS feed.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
Who is the host of this show?
What does HPR mean to you?